﻿using System;
using System.Linq;
using System.Drawing;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Windows.Forms;
using System.Text;
using System.Data;
using System.Data.OleDb;
using System.Data.Odbc;
using System.Data.SqlClient;
using System.IO;
using System.Globalization;
using System.Xml;
using ESRI.ArcGIS.esriSystem;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.Geodatabase;
using System.Drawing.Printing;
using PlanningGIS.Statistics;
using ESRI.ArcGIS.Controls;
using System.Runtime.InteropServices;
using PlanningGIS.Framework.Controls;
using DevComponents.DotNetBar;
using DevComponents.DotNetBar.Controls;
using PlanningGIS.Statistics;
using PlanningGIS.Framework;
using ESRI.ArcGIS.Geometry;
using ESRI.ArcGIS.Display;
using PlanningGIS.Win.Controls;

using PlanningGIS.ArcGIS;
using PlanningGIS.ArcGIS.Custom;
using PlanningGIS.Engine.Controls;
using PlanningGIS.Util;
using DevComponents.DotNetBar.SuperGrid;
using PlanningGIS.MapSheet;

namespace PlanningGIS.Statistics
{
    /// <summary>
    /// 名    称：FrmCustomReport
    /// 作    用：创建自定义统计报表对话框
    /// 开发人员：张利勇
    /// 开发日期：2009-06-13
    /// 修改人员：
    /// 修改日期：
    /// 修改说明：
    /// </summary>
    public class FrmCustomReport : Office2007Form
    {
        #region User Define 
        private IApplication m_Application = null;
        private IPolygon pPolygonCustom; //自定义导出范围图形
        private IPolygon pPolygonSurvey;//按测区范围
        private IElement m_pElementUserDraw;
        IMapControl3 m_pMapCtl = null;
        IFeatureClass _pFeatClass = null;
        private List<SqlColumn> _ColumnList = null;
        DataTable m_Tab = new DataTable();
        DataTable m_FilterTab = new DataTable();
        PrintDocument printEngine = new PrintDocument();
        ReportClass objRepLib = new ReportClass();
        private int FeatureCount = 0;  
        string FilterLayerName; //已过滤后的所选图层名
        private PagedGrid pagedGrid = new PagedGrid();
        private IContainer components;
        private IElement m_pElementUserPrivilege;
        private DevComponents.DotNetBar.TabControlPanel tabControlPanel10;
        private DevComponents.DotNetBar.TabControl tcDialog;
        private DevComponents.DotNetBar.TabControlPanel tabControlPanel15;
        private DevComponents.DotNetBar.TabItem tabItem5;
        private DevComponents.DotNetBar.TabControlPanel tabControlPanel16;
        private DevComponents.DotNetBar.TabItem tabItem4;
        private TextBox tbSQL;
        private TreeView tvTablesColumns;
        private ButtonX bDel;
        private ButtonX bDelOne;
        private ButtonX bMove;
        private ButtonX bMoveOne;
        private LabelX label10;
        private LabelX label9;
        private ListBox listSelectCols;
        private DevComponents.DotNetBar.Controls.GroupPanel groupBox5;
        private DevComponents.DotNetBar.TabItem tabItem3;

        private DevComponents.DotNetBar.TabItem tabItem2;
        private DevComponents.DotNetBar.TabControlPanel tabControlPanel17;

        private DevComponents.DotNetBar.TabControlPanel tabControlPanel1;
        private DevComponents.DotNetBar.TabItem tabItem8;
        private TextBox tbReportName;
        private LabelX label1;
        private DataGridViewX dataGridViewX1;
        private PrintPreviewDialog printPrevDiag;
        private GroupPanel gb_Settings;
        private ButtonX btn_Print;
        private ButtonX btn_PrintSettings;
        private ButtonX btn_PageSettings;
        private ButtonX btn_PrintPreviw;
        private ButtonX btn_AddAggr;
        private ComboBoxEx combo_Aggr;
        private DataGridViewTextBoxColumn Column1;
        private DataGridViewTextBoxColumn Column2;
        private ButtonX btn_PreviewTable;
        private CheckBoxX checkBox3;
        private LabelX label2;
        private ButtonX button_Prev;
        private ButtonX button_Next;
        private ButtonX btnCancel;
        private ButtonX btn_Cancel2;
        private PrintDocument printDocument1;
        private CheckBoxX chkUseCstExt;
        private DevComponents.DotNetBar.TabControl tabControl1;
        private TabControlPanel tabControlPanel4;
        private TabItem tabItem6;
        private TabControlPanel tabControlPanel5;
        private TabItem tabItem11;
        private ButtonX btn_Del;
        private Engine.Controls.LayersComboBox combo_FLayer;
        private ComboBoxEx combo_Cols;
        /// <summary>
        /// 地图关联对象
        /// </summary>
        private IHookHelper m_HookHelp = null;

        /// <summary>
        /// 绘制工具构建对象
        /// </summary>
        private ToolCreator _ToolCreator = null;

        /// <summary>
        /// 结合表选择构建对象
        /// </summary>
        private SheetCreator _SheetCreator = null;
        private SuperTabControl sptbctlGeo;
        private SuperTabControlPanel superTabControlPanel1;
        private Bar barSheet;
        private ButtonItem btnSelAllSheet;
        private ButtonItem btnNoSelSheet;
        private ButtonItem btnReverSelSheet;
        private DevComponents.DotNetBar.SuperGrid.SuperGridControl spgrdSheet;
        private SuperTabItem sptbitmSheet;
        private SuperTabControlPanel superTabControlPanel5;
        private RichTextBoxEx txtTip;
        private SuperTabItem sptbitmPoly;
        private SuperTabControlPanel superTabControlPanel2;
        private RegionTree regionTree;
        private DevComponents.AdvTree.NodeConnector nodeConnector1;
        private ElementStyle elementStyle1;
        private SuperTabItem sptbitmRegion;
        private ComboBoxItem cmbScale;
        private ButtonItem btnDrawExtent;
        
        #endregion

        private Type ConvertEsriFieldType(esriFieldType esType)
        {
            if (esType == esriFieldType.esriFieldTypeDate)
                return typeof(DateTime);
            else if (esType == esriFieldType.esriFieldTypeDouble)
                return typeof(Double);
            else if (esType == esriFieldType.esriFieldTypeSmallInteger)
                return typeof(short);
            else if (esType == esriFieldType.esriFieldTypeInteger)
                return typeof(int);
            else if (esType == esriFieldType.esriFieldTypeOID)
                return typeof(long);
            else if (esType == esriFieldType.esriFieldTypeSingle)
                return typeof(Single);
            else if (esType == esriFieldType.esriFieldTypeString)
                return typeof(String);
            else
                return typeof(Byte[]);
        }

        private DataTable CreateDTFrameFromITable(ITable table, string TabName)
        {
            DataTable ExpertInfo = new DataTable(TabName);
            try
            {
                IQueryFilter que = new QueryFilterClass();
                ICursor pCursor = table.Search(que, true);
                IRow pRow = pCursor.NextRow();
                FeatureCount = table.RowCount(null);
                if (pRow != null)
                {
                    for (int i = 0; i < pRow.Fields.FieldCount; i++)
                    {
                        Type pType = ConvertEsriFieldType(pRow.Fields.get_Field(i).Type);
                        if (pType != typeof(Byte[]))
                        {
                            ExpertInfo.Columns.Add(pRow.Fields.get_Field(i).Name, pType);
                        }
                    }
                }
            }
            catch (System.Exception ex)
            {
                MsgHelper.ShowErrorMsgbox("自定义统计出错:" + ex.Message);
            }
            return ExpertInfo;
        }

        private DataTable ConvertITable(ITable table, string TabName)
        {
            DataTable ExpertInfo = new DataTable(TabName);
            try
            {
                IQueryFilter que = new QueryFilterClass();
                ICursor pCursor = table.Search(que, true);
                IRow pRow = pCursor.NextRow();
                
                if (pRow != null)
                {
                    List<Type> FieldTypeList = new List<Type>();
                    List<int> FieldIndexList = new List<int>();
                    for (int i = 0; i < pRow.Fields.FieldCount; i++)
                    {
                        Type pType = ConvertEsriFieldType(pRow.Fields.get_Field(i).Type);
                        FieldTypeList.Add(pType);
                        if (pType != typeof(Byte[]))
                        {
                            FieldIndexList.Add(i);
                            ExpertInfo.Columns.Add(pRow.Fields.get_Field(i).Name, pType);
                        }
                    }
                    while (pRow != null)
                    {
                        DataRow pDataRow = ExpertInfo.NewRow();

                        for (int i = 0; i < FieldIndexList.Count; i++)
                        {
                            pDataRow[i] = pRow.get_Value(FieldIndexList[i]);
                        }
                        ExpertInfo.Rows.Add(pDataRow);
                        pRow = pCursor.NextRow();
                    }
                }
            }
            catch (System.Exception ex)
            {
                MsgHelper.ShowErrorMsgbox("自定义统计出错:" + ex.Message);
            }

            return ExpertInfo;
        }

        //根据所选字段，对m_FilterTable进行重新生成：
        //如果m_FilterTab.Columns.Count == 0, 则重写生成m_FilterTab的Columns
        //否则判断m_FilterTab.Columns是否合格，不合格的话，也要重写生成m_FilterTab的Columns
        private void FilterTable(DataTable table, List<string> Columns)
        {
            try
            {
                int j = 0, i=0;

                if (m_FilterTab.Columns.Count == Columns.Count)
                {
                    for (i = 0; i < Columns.Count; i++)
                    {
                        if (table.Columns[i].ColumnName != Columns[i])
                            break;
                    }

                    if (i == Columns.Count)
                        return;
                }

                m_FilterTab = new DataTable(table.TableName, "ss");
                List<int> ColIndexList = new List<int>();
                for (i = 0; i < Columns.Count; i++)
                {
                    for (j = 0; j < table.Columns.Count; j++)
                    {
                        if (table.Columns[j].ColumnName == Columns[i])
                        {
                            m_FilterTab.Columns.Add(table.Columns[j].ColumnName, table.Columns[j].DataType);
                            break;
                        }
                    }
                }
                return;

            }
            catch (System.Exception ex)
            {
                MsgHelper.ShowErrorMsgbox("自定义统计出错:" + ex.Message);
            }
        }

        /// <summary>
        /// 对m_FilterTab.Rows填充数据
        /// </summary>
        /// <param name="table"></param>
        /// <returns></returns>
        private int FillFilterTable(ITable table)
        {
            //如果m_FilterTab.Rows已经填充了数据，就不需要再填充了
            if ((combo_FLayer.Text == FilterLayerName) && (m_FilterTab.Rows.Count == FeatureCount)) return 0;

            pagedGrid.GetGridView().AutoGenerateColumns = false;
            pagedGrid.GetGridView().Columns.Clear();
            IFields fields = _pFeatClass.Fields;
            for (int num = 0; num < m_FilterTab.Columns.Count; num++)
            {
                DataGridViewColumn col = new DataGridViewTextBoxColumn();
                col.HeaderText = m_FilterTab.Columns[num].ColumnName;
                col.Name = m_FilterTab.Columns[num].ColumnName;
                col.DataPropertyName = m_FilterTab.Columns[num].ColumnName;
                
                pagedGrid.GetGridView().Columns.Add(col);
            }
            pagedGrid.ResetDataSource((uint)FeatureCount);

            return 1;
        }

        /// <summary>
        /// 构造函数 
        /// </summary>
        /// <param name="pMapCtl"></param>
        public FrmCustomReport(IApplication value,IMapControl3 pMapCtl)
		{
            m_Application = value;
            m_pMapCtl = pMapCtl;
            m_HookHelp = new HookHelper();
            m_HookHelp.Hook = (value as IFramework).Object;
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
            this.components = new System.ComponentModel.Container();
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmCustomReport));
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
            this.tabControlPanel10 = new DevComponents.DotNetBar.TabControlPanel();
            this.tcDialog = new DevComponents.DotNetBar.TabControl();
            this.tabControlPanel15 = new DevComponents.DotNetBar.TabControlPanel();
            this.chkUseCstExt = new DevComponents.DotNetBar.Controls.CheckBoxX();
            this.tabControl1 = new DevComponents.DotNetBar.TabControl();
            this.tabControlPanel5 = new DevComponents.DotNetBar.TabControlPanel();
            this.sptbctlGeo = new DevComponents.DotNetBar.SuperTabControl();
            this.superTabControlPanel1 = new DevComponents.DotNetBar.SuperTabControlPanel();
            this.barSheet = new DevComponents.DotNetBar.Bar();
            this.btnSelAllSheet = new DevComponents.DotNetBar.ButtonItem();
            this.btnNoSelSheet = new DevComponents.DotNetBar.ButtonItem();
            this.btnReverSelSheet = new DevComponents.DotNetBar.ButtonItem();
            this.spgrdSheet = new DevComponents.DotNetBar.SuperGrid.SuperGridControl();
            this.sptbitmSheet = new DevComponents.DotNetBar.SuperTabItem();
            this.superTabControlPanel5 = new DevComponents.DotNetBar.SuperTabControlPanel();
            this.txtTip = new DevComponents.DotNetBar.Controls.RichTextBoxEx();
            this.sptbitmPoly = new DevComponents.DotNetBar.SuperTabItem();
            this.superTabControlPanel2 = new DevComponents.DotNetBar.SuperTabControlPanel();
            this.regionTree = new PlanningGIS.Framework.Controls.RegionTree(this.components);
            this.nodeConnector1 = new DevComponents.AdvTree.NodeConnector();
            this.elementStyle1 = new DevComponents.DotNetBar.ElementStyle();
            this.sptbitmRegion = new DevComponents.DotNetBar.SuperTabItem();
            this.cmbScale = new DevComponents.DotNetBar.ComboBoxItem();
            this.btnDrawExtent = new DevComponents.DotNetBar.ButtonItem();
            this.tabItem11 = new DevComponents.DotNetBar.TabItem(this.components);
            this.tabControlPanel4 = new DevComponents.DotNetBar.TabControlPanel();
            this.btn_Del = new DevComponents.DotNetBar.ButtonX();
            this.btn_AddAggr = new DevComponents.DotNetBar.ButtonX();
            this.dataGridViewX1 = new DevComponents.DotNetBar.Controls.DataGridViewX();
            this.Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.Column2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.combo_Aggr = new DevComponents.DotNetBar.Controls.ComboBoxEx();
            this.combo_Cols = new DevComponents.DotNetBar.Controls.ComboBoxEx();
            this.tabItem6 = new DevComponents.DotNetBar.TabItem(this.components);
            this.btn_PreviewTable = new DevComponents.DotNetBar.ButtonX();
            this.checkBox3 = new DevComponents.DotNetBar.Controls.CheckBoxX();
            this.gb_Settings = new DevComponents.DotNetBar.Controls.GroupPanel();
            this.btn_Print = new DevComponents.DotNetBar.ButtonX();
            this.btn_PrintSettings = new DevComponents.DotNetBar.ButtonX();
            this.btn_PageSettings = new DevComponents.DotNetBar.ButtonX();
            this.btn_PrintPreviw = new DevComponents.DotNetBar.ButtonX();
            this.tbReportName = new System.Windows.Forms.TextBox();
            this.label1 = new DevComponents.DotNetBar.LabelX();
            this.button_Prev = new DevComponents.DotNetBar.ButtonX();
            this.btnCancel = new DevComponents.DotNetBar.ButtonX();
            this.tabItem5 = new DevComponents.DotNetBar.TabItem(this.components);
            this.tabControlPanel16 = new DevComponents.DotNetBar.TabControlPanel();
            this.combo_FLayer = new PlanningGIS.Engine.Controls.LayersComboBox(this.components);
            this.btn_Cancel2 = new DevComponents.DotNetBar.ButtonX();
            this.button_Next = new DevComponents.DotNetBar.ButtonX();
            this.label2 = new DevComponents.DotNetBar.LabelX();
            this.groupBox5 = new DevComponents.DotNetBar.Controls.GroupPanel();
            this.listSelectCols = new System.Windows.Forms.ListBox();
            this.bDel = new DevComponents.DotNetBar.ButtonX();
            this.bDelOne = new DevComponents.DotNetBar.ButtonX();
            this.bMove = new DevComponents.DotNetBar.ButtonX();
            this.bMoveOne = new DevComponents.DotNetBar.ButtonX();
            this.label10 = new DevComponents.DotNetBar.LabelX();
            this.label9 = new DevComponents.DotNetBar.LabelX();
            this.tbSQL = new System.Windows.Forms.TextBox();
            this.tvTablesColumns = new System.Windows.Forms.TreeView();
            this.tabItem4 = new DevComponents.DotNetBar.TabItem(this.components);
            this.tabControlPanel1 = new DevComponents.DotNetBar.TabControlPanel();
            this.tabItem8 = new DevComponents.DotNetBar.TabItem(this.components);
            this.tabItem3 = new DevComponents.DotNetBar.TabItem(this.components);
            this.tabItem2 = new DevComponents.DotNetBar.TabItem(this.components);
            this.tabControlPanel17 = new DevComponents.DotNetBar.TabControlPanel();
            this.printPrevDiag = new System.Windows.Forms.PrintPreviewDialog();
            this.printDocument1 = new System.Drawing.Printing.PrintDocument();
            ((System.ComponentModel.ISupportInitialize)(this.tcDialog)).BeginInit();
            this.tcDialog.SuspendLayout();
            this.tabControlPanel15.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.tabControl1)).BeginInit();
            this.tabControl1.SuspendLayout();
            this.tabControlPanel5.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.sptbctlGeo)).BeginInit();
            this.sptbctlGeo.SuspendLayout();
            this.superTabControlPanel1.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.barSheet)).BeginInit();
            this.superTabControlPanel5.SuspendLayout();
            this.superTabControlPanel2.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.regionTree)).BeginInit();
            this.tabControlPanel4.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.dataGridViewX1)).BeginInit();
            this.gb_Settings.SuspendLayout();
            this.tabControlPanel16.SuspendLayout();
            this.groupBox5.SuspendLayout();
            this.SuspendLayout();
            // 
            // tabControlPanel10
            // 
            this.tabControlPanel10.DisabledBackColor = System.Drawing.Color.Empty;
            this.tabControlPanel10.Dock = System.Windows.Forms.DockStyle.Fill;
            this.tabControlPanel10.Location = new System.Drawing.Point(0, 26);
            this.tabControlPanel10.Name = "tabControlPanel10";
            this.tabControlPanel10.Padding = new System.Windows.Forms.Padding(1);
            this.tabControlPanel10.Size = new System.Drawing.Size(544, 244);
            this.tabControlPanel10.Style.BackColor1.Color = System.Drawing.Color.FromArgb(((int)(((byte)(142)))), ((int)(((byte)(179)))), ((int)(((byte)(231)))));
            this.tabControlPanel10.Style.BackColor2.Color = System.Drawing.Color.FromArgb(((int)(((byte)(223)))), ((int)(((byte)(237)))), ((int)(((byte)(254)))));
            this.tabControlPanel10.Style.Border = DevComponents.DotNetBar.eBorderType.SingleLine;
            this.tabControlPanel10.Style.BorderColor.Color = System.Drawing.Color.FromArgb(((int)(((byte)(59)))), ((int)(((byte)(97)))), ((int)(((byte)(156)))));
            this.tabControlPanel10.Style.BorderSide = ((DevComponents.DotNetBar.eBorderSide)(((DevComponents.DotNetBar.eBorderSide.Left | DevComponents.DotNetBar.eBorderSide.Right) 
            | DevComponents.DotNetBar.eBorderSide.Bottom)));
            this.tabControlPanel10.Style.GradientAngle = 90;
            this.tabControlPanel10.TabIndex = 6;
            // 
            // tcDialog
            // 
            this.tcDialog.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(194)))), ((int)(((byte)(217)))), ((int)(((byte)(247)))));
            this.tcDialog.CanReorderTabs = true;
            this.tcDialog.Controls.Add(this.tabControlPanel16);
            this.tcDialog.Controls.Add(this.tabControlPanel15);
            this.tcDialog.Controls.Add(this.tabControlPanel1);
            this.tcDialog.Dock = System.Windows.Forms.DockStyle.Fill;
            this.tcDialog.ForeColor = System.Drawing.Color.Black;
            this.tcDialog.Location = new System.Drawing.Point(0, 0);
            this.tcDialog.Name = "tcDialog";
            this.tcDialog.SelectedTabFont = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold);
            this.tcDialog.SelectedTabIndex = 0;
            this.tcDialog.Size = new System.Drawing.Size(547, 385);
            this.tcDialog.Style = DevComponents.DotNetBar.eTabStripStyle.Office2007Document;
            this.tcDialog.TabIndex = 0;
            this.tcDialog.TabLayoutType = DevComponents.DotNetBar.eTabLayoutType.FixedWithNavigationBox;
            this.tcDialog.Tabs.Add(this.tabItem4);
            this.tcDialog.Tabs.Add(this.tabItem5);
            this.tcDialog.Tabs.Add(this.tabItem8);
            this.tcDialog.TabsVisible = false;
            this.tcDialog.Text = "预览";
            this.tcDialog.SelectedTabChanged += new DevComponents.DotNetBar.TabStrip.SelectedTabChangedEventHandler(this.tabControl1_SelectedIndexChanged);
            // 
            // tabControlPanel15
            // 
            this.tabControlPanel15.Controls.Add(this.chkUseCstExt);
            this.tabControlPanel15.Controls.Add(this.tabControl1);
            this.tabControlPanel15.Controls.Add(this.btn_PreviewTable);
            this.tabControlPanel15.Controls.Add(this.checkBox3);
            this.tabControlPanel15.Controls.Add(this.gb_Settings);
            this.tabControlPanel15.Controls.Add(this.tbReportName);
            this.tabControlPanel15.Controls.Add(this.label1);
            this.tabControlPanel15.Controls.Add(this.button_Prev);
            this.tabControlPanel15.Controls.Add(this.btnCancel);
            this.tabControlPanel15.DisabledBackColor = System.Drawing.Color.Empty;
            this.tabControlPanel15.Dock = System.Windows.Forms.DockStyle.Fill;
            this.tabControlPanel15.Location = new System.Drawing.Point(0, 25);
            this.tabControlPanel15.Name = "tabControlPanel15";
            this.tabControlPanel15.Padding = new System.Windows.Forms.Padding(1);
            this.tabControlPanel15.Size = new System.Drawing.Size(547, 360);
            this.tabControlPanel15.Style.BackColor1.Color = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))));
            this.tabControlPanel15.Style.Border = DevComponents.DotNetBar.eBorderType.SingleLine;
            this.tabControlPanel15.Style.BorderColor.Color = System.Drawing.Color.FromArgb(((int)(((byte)(204)))), ((int)(((byte)(204)))), ((int)(((byte)(204)))));
            this.tabControlPanel15.Style.BorderSide = ((DevComponents.DotNetBar.eBorderSide)(((DevComponents.DotNetBar.eBorderSide.Left | DevComponents.DotNetBar.eBorderSide.Right) 
            | DevComponents.DotNetBar.eBorderSide.Bottom)));
            this.tabControlPanel15.Style.GradientAngle = 90;
            this.tabControlPanel15.TabIndex = 5;
            this.tabControlPanel15.TabItem = this.tabItem5;
            // 
            // chkUseCstExt
            // 
            this.chkUseCstExt.AutoSize = true;
            this.chkUseCstExt.BackColor = System.Drawing.Color.Transparent;
            // 
            // 
            // 
            this.chkUseCstExt.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
            this.chkUseCstExt.Location = new System.Drawing.Point(151, 37);
            this.chkUseCstExt.Name = "chkUseCstExt";
            this.chkUseCstExt.Size = new System.Drawing.Size(113, 18);
            this.chkUseCstExt.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
            this.chkUseCstExt.TabIndex = 29;
            this.chkUseCstExt.Text = "使用自定义范围";
            this.chkUseCstExt.CheckedChanged += new System.EventHandler(this.chkUseCstExt_CheckedChanged);
            // 
            // tabControl1
            // 
            this.tabControl1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))));
            this.tabControl1.CanReorderTabs = true;
            this.tabControl1.Controls.Add(this.tabControlPanel4);
            this.tabControl1.Controls.Add(this.tabControlPanel5);
            this.tabControl1.ForeColor = System.Drawing.Color.Black;
            this.tabControl1.Location = new System.Drawing.Point(7, 64);
            this.tabControl1.Name = "tabControl1";
            this.tabControl1.SelectedTabFont = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold);
            this.tabControl1.SelectedTabIndex = 0;
            this.tabControl1.Size = new System.Drawing.Size(370, 272);
            this.tabControl1.Style = DevComponents.DotNetBar.eTabStripStyle.Office2007Document;
            this.tabControl1.TabIndex = 28;
            this.tabControl1.TabLayoutType = DevComponents.DotNetBar.eTabLayoutType.FixedWithNavigationBox;
            this.tabControl1.Tabs.Add(this.tabItem6);
            this.tabControl1.Tabs.Add(this.tabItem11);
            this.tabControl1.Text = "tabControl1";
            // 
            // tabControlPanel5
            // 
            this.tabControlPanel5.Controls.Add(this.sptbctlGeo);
            this.tabControlPanel5.DisabledBackColor = System.Drawing.Color.Empty;
            this.tabControlPanel5.Dock = System.Windows.Forms.DockStyle.Fill;
            this.tabControlPanel5.Location = new System.Drawing.Point(0, 25);
            this.tabControlPanel5.Name = "tabControlPanel5";
            this.tabControlPanel5.Padding = new System.Windows.Forms.Padding(1);
            this.tabControlPanel5.Size = new System.Drawing.Size(370, 247);
            this.tabControlPanel5.Style.BackColor1.Color = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))));
            this.tabControlPanel5.Style.Border = DevComponents.DotNetBar.eBorderType.SingleLine;
            this.tabControlPanel5.Style.BorderColor.Color = System.Drawing.Color.FromArgb(((int)(((byte)(204)))), ((int)(((byte)(204)))), ((int)(((byte)(204)))));
            this.tabControlPanel5.Style.BorderSide = ((DevComponents.DotNetBar.eBorderSide)(((DevComponents.DotNetBar.eBorderSide.Left | DevComponents.DotNetBar.eBorderSide.Right) 
            | DevComponents.DotNetBar.eBorderSide.Bottom)));
            this.tabControlPanel5.Style.GradientAngle = 90;
            this.tabControlPanel5.TabIndex = 2;
            this.tabControlPanel5.TabItem = this.tabItem11;
            // 
            // sptbctlGeo
            // 
            this.sptbctlGeo.BackColor = System.Drawing.Color.White;
            // 
            // 
            // 
            // 
            // 
            // 
            this.sptbctlGeo.ControlBox.CloseBox.Name = "";
            // 
            // 
            // 
            this.sptbctlGeo.ControlBox.MenuBox.Name = "";
            this.sptbctlGeo.ControlBox.Name = "";
            this.sptbctlGeo.ControlBox.SubItems.AddRange(new DevComponents.DotNetBar.BaseItem[] {
            this.sptbctlGeo.ControlBox.MenuBox,
            this.sptbctlGeo.ControlBox.CloseBox});
            this.sptbctlGeo.Controls.Add(this.superTabControlPanel1);
            this.sptbctlGeo.Controls.Add(this.superTabControlPanel5);
            this.sptbctlGeo.Controls.Add(this.superTabControlPanel2);
            this.sptbctlGeo.Dock = System.Windows.Forms.DockStyle.Fill;
            this.sptbctlGeo.ForeColor = System.Drawing.Color.Black;
            this.sptbctlGeo.Location = new System.Drawing.Point(1, 1);
            this.sptbctlGeo.Name = "sptbctlGeo";
            this.sptbctlGeo.ReorderTabsEnabled = true;
            this.sptbctlGeo.SelectedTabFont = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold);
            this.sptbctlGeo.SelectedTabIndex = 0;
            this.sptbctlGeo.Size = new System.Drawing.Size(368, 245);
            this.sptbctlGeo.TabFont = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.sptbctlGeo.TabHorizontalSpacing = 3;
            this.sptbctlGeo.TabIndex = 57;
            this.sptbctlGeo.Tabs.AddRange(new DevComponents.DotNetBar.BaseItem[] {
            this.sptbitmSheet,
            this.cmbScale,
            this.sptbitmRegion,
            this.sptbitmPoly,
            this.btnDrawExtent});
            this.sptbctlGeo.Text = "导出范围";
            this.sptbctlGeo.SelectedTabChanged += new System.EventHandler<DevComponents.DotNetBar.SuperTabStripSelectedTabChangedEventArgs>(this.sptbctlGeo_SelectedTabChanged);
            // 
            // superTabControlPanel1
            // 
            this.superTabControlPanel1.Controls.Add(this.barSheet);
            this.superTabControlPanel1.Controls.Add(this.spgrdSheet);
            this.superTabControlPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
            this.superTabControlPanel1.Location = new System.Drawing.Point(0, 28);
            this.superTabControlPanel1.Name = "superTabControlPanel1";
            this.superTabControlPanel1.Size = new System.Drawing.Size(368, 217);
            this.superTabControlPanel1.TabIndex = 1;
            this.superTabControlPanel1.TabItem = this.sptbitmSheet;
            // 
            // barSheet
            // 
            this.barSheet.AntiAlias = true;
            this.barSheet.Dock = System.Windows.Forms.DockStyle.Bottom;
            this.barSheet.DockSide = DevComponents.DotNetBar.eDockSide.Document;
            this.barSheet.Font = new System.Drawing.Font("微软雅黑", 9F);
            this.barSheet.IsMaximized = false;
            this.barSheet.Items.AddRange(new DevComponents.DotNetBar.BaseItem[] {
            this.btnSelAllSheet,
            this.btnNoSelSheet,
            this.btnReverSelSheet});
            this.barSheet.Location = new System.Drawing.Point(0, 190);
            this.barSheet.Name = "barSheet";
            this.barSheet.Size = new System.Drawing.Size(368, 27);
            this.barSheet.Stretch = true;
            this.barSheet.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
            this.barSheet.TabIndex = 3;
            this.barSheet.TabStop = false;
            this.barSheet.Text = "barArea";
            // 
            // btnSelAllSheet
            // 
            this.btnSelAllSheet.BeginGroup = true;
            this.btnSelAllSheet.Name = "btnSelAllSheet";
            this.btnSelAllSheet.Text = "全选";
            this.btnSelAllSheet.Click += new System.EventHandler(this.btnSelAllSheet_Click);
            // 
            // btnNoSelSheet
            // 
            this.btnNoSelSheet.Name = "btnNoSelSheet";
            this.btnNoSelSheet.Text = "全不选";
            this.btnNoSelSheet.Click += new System.EventHandler(this.btnNoSelSheet_Click);
            // 
            // btnReverSelSheet
            // 
            this.btnReverSelSheet.Name = "btnReverSelSheet";
            this.btnReverSelSheet.Text = "反选";
            this.btnReverSelSheet.Click += new System.EventHandler(this.btnReverSelSheet_Click);
            // 
            // spgrdSheet
            // 
            this.spgrdSheet.BackColor = System.Drawing.Color.White;
            this.spgrdSheet.Dock = System.Windows.Forms.DockStyle.Fill;
            this.spgrdSheet.Enabled = false;
            this.spgrdSheet.FilterExprColors.SysFunction = System.Drawing.Color.DarkRed;
            this.spgrdSheet.ForeColor = System.Drawing.Color.Black;
            this.spgrdSheet.Location = new System.Drawing.Point(0, 0);
            this.spgrdSheet.Name = "spgrdSheet";
            // 
            // 
            // 
            // 
            // 
            // 
            this.spgrdSheet.PrimaryGrid.ColumnHeader.RowHeight = 22;
            this.spgrdSheet.Size = new System.Drawing.Size(368, 217);
            this.spgrdSheet.TabIndex = 0;
            this.spgrdSheet.Text = "superGridControl1";
            // 
            // sptbitmSheet
            // 
            this.sptbitmSheet.AttachedControl = this.superTabControlPanel1;
            this.sptbitmSheet.GlobalItem = false;
            this.sptbitmSheet.Name = "sptbitmSheet";
            this.sptbitmSheet.Text = "图幅";
            this.sptbitmSheet.Tooltip = "按图幅拆分时，导出成一张张的图幅；按范围导出时，将所有图幅合并成一个范围，再进行导出";
            // 
            // superTabControlPanel5
            // 
            this.superTabControlPanel5.Controls.Add(this.txtTip);
            this.superTabControlPanel5.Dock = System.Windows.Forms.DockStyle.Fill;
            this.superTabControlPanel5.Location = new System.Drawing.Point(0, 28);
            this.superTabControlPanel5.Name = "superTabControlPanel5";
            this.superTabControlPanel5.Size = new System.Drawing.Size(368, 217);
            this.superTabControlPanel5.TabIndex = 0;
            this.superTabControlPanel5.TabItem = this.sptbitmPoly;
            // 
            // txtTip
            // 
            // 
            // 
            // 
            this.txtTip.BackgroundStyle.Class = "RichTextBoxBorder";
            this.txtTip.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
            this.txtTip.Dock = System.Windows.Forms.DockStyle.Fill;
            this.txtTip.Font = new System.Drawing.Font("宋体", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.txtTip.Location = new System.Drawing.Point(0, 0);
            this.txtTip.Name = "txtTip";
            this.txtTip.ReadOnly = true;
            this.txtTip.Rtf = resources.GetString("txtTip.Rtf");
            this.txtTip.Size = new System.Drawing.Size(368, 217);
            this.txtTip.TabIndex = 0;
            this.txtTip.Text = "请使用绘图工具在地图中绘制所需要统计的范围";
            // 
            // sptbitmPoly
            // 
            this.sptbitmPoly.AttachedControl = this.superTabControlPanel5;
            this.sptbitmPoly.GlobalItem = false;
            this.sptbitmPoly.Name = "sptbitmPoly";
            this.sptbitmPoly.Text = "自定义范围";
            // 
            // superTabControlPanel2
            // 
            this.superTabControlPanel2.Controls.Add(this.regionTree);
            this.superTabControlPanel2.Dock = System.Windows.Forms.DockStyle.Fill;
            this.superTabControlPanel2.Location = new System.Drawing.Point(0, 28);
            this.superTabControlPanel2.Name = "superTabControlPanel2";
            this.superTabControlPanel2.Size = new System.Drawing.Size(368, 217);
            this.superTabControlPanel2.TabIndex = 0;
            this.superTabControlPanel2.TabItem = this.sptbitmRegion;
            // 
            // regionTree
            // 
            this.regionTree.AccessibleRole = System.Windows.Forms.AccessibleRole.Outline;
            this.regionTree.AllowDrop = true;
            this.regionTree.BackColor = System.Drawing.SystemColors.Window;
            // 
            // 
            // 
            this.regionTree.BackgroundStyle.Class = "TreeBorderKey";
            this.regionTree.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
            this.regionTree.Dock = System.Windows.Forms.DockStyle.Fill;
            this.regionTree.DragDropEnabled = false;
            this.regionTree.DragDropNodeCopyEnabled = false;
            this.regionTree.Enabled = false;
            this.regionTree.IsToMap = true;
            this.regionTree.Location = new System.Drawing.Point(0, 0);
            this.regionTree.Name = "regionTree";
            this.regionTree.NodesConnector = this.nodeConnector1;
            this.regionTree.NodeStyle = this.elementStyle1;
            this.regionTree.PathSeparator = ";";
            this.regionTree.SelectedRegions = null;
            this.regionTree.Size = new System.Drawing.Size(368, 217);
            this.regionTree.Styles.Add(this.elementStyle1);
            this.regionTree.TabIndex = 1;
            this.regionTree.Text = "行政区划树";
            // 
            // nodeConnector1
            // 
            this.nodeConnector1.LineColor = System.Drawing.SystemColors.ControlText;
            // 
            // elementStyle1
            // 
            this.elementStyle1.CornerType = DevComponents.DotNetBar.eCornerType.Square;
            this.elementStyle1.Name = "elementStyle1";
            this.elementStyle1.TextColor = System.Drawing.SystemColors.ControlText;
            // 
            // sptbitmRegion
            // 
            this.sptbitmRegion.AttachedControl = this.superTabControlPanel2;
            this.sptbitmRegion.GlobalItem = false;
            this.sptbitmRegion.Name = "sptbitmRegion";
            this.sptbitmRegion.Text = "行政区";
            // 
            // cmbScale
            // 
            this.cmbScale.ComboWidth = 55;
            this.cmbScale.DropDownHeight = 106;
            this.cmbScale.ItemHeight = 16;
            this.cmbScale.Name = "cmbScale";
            this.cmbScale.SelectedIndexChanged += new System.EventHandler(this.cmbScale_SelectedIndexChanged);
            // 
            // btnDrawExtent
            // 
            this.btnDrawExtent.Enabled = false;
            this.btnDrawExtent.Image = ((System.Drawing.Image)(resources.GetObject("btnDrawExtent.Image")));
            this.btnDrawExtent.Name = "btnDrawExtent";
            this.btnDrawExtent.Text = "选择";
            this.btnDrawExtent.Tooltip = "在地图中绘制范围，用来选择图幅、行政区或绘制自定义统计范围。";
            // 
            // tabItem11
            // 
            this.tabItem11.AttachedControl = this.tabControlPanel5;
            this.tabItem11.Name = "tabItem11";
            this.tabItem11.Text = "选择范围";
            // 
            // tabControlPanel4
            // 
            this.tabControlPanel4.Controls.Add(this.btn_Del);
            this.tabControlPanel4.Controls.Add(this.btn_AddAggr);
            this.tabControlPanel4.Controls.Add(this.dataGridViewX1);
            this.tabControlPanel4.Controls.Add(this.combo_Aggr);
            this.tabControlPanel4.Controls.Add(this.combo_Cols);
            this.tabControlPanel4.DisabledBackColor = System.Drawing.Color.Empty;
            this.tabControlPanel4.Dock = System.Windows.Forms.DockStyle.Fill;
            this.tabControlPanel4.Location = new System.Drawing.Point(0, 25);
            this.tabControlPanel4.Name = "tabControlPanel4";
            this.tabControlPanel4.Padding = new System.Windows.Forms.Padding(1);
            this.tabControlPanel4.Size = new System.Drawing.Size(370, 247);
            this.tabControlPanel4.Style.BackColor1.Color = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))));
            this.tabControlPanel4.Style.Border = DevComponents.DotNetBar.eBorderType.SingleLine;
            this.tabControlPanel4.Style.BorderColor.Color = System.Drawing.Color.FromArgb(((int)(((byte)(204)))), ((int)(((byte)(204)))), ((int)(((byte)(204)))));
            this.tabControlPanel4.Style.BorderSide = ((DevComponents.DotNetBar.eBorderSide)(((DevComponents.DotNetBar.eBorderSide.Left | DevComponents.DotNetBar.eBorderSide.Right) 
            | DevComponents.DotNetBar.eBorderSide.Bottom)));
            this.tabControlPanel4.Style.GradientAngle = 90;
            this.tabControlPanel4.TabIndex = 1;
            this.tabControlPanel4.TabItem = this.tabItem6;
            // 
            // btn_Del
            // 
            this.btn_Del.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
            this.btn_Del.Location = new System.Drawing.Point(315, 24);
            this.btn_Del.Name = "btn_Del";
            this.btn_Del.Size = new System.Drawing.Size(50, 22);
            this.btn_Del.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
            this.btn_Del.TabIndex = 19;
            this.btn_Del.Text = "删除";
            this.btn_Del.Click += new System.EventHandler(this.btn_Del_Click);
            // 
            // btn_AddAggr
            // 
            this.btn_AddAggr.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
            this.btn_AddAggr.Location = new System.Drawing.Point(228, 25);
            this.btn_AddAggr.Name = "btn_AddAggr";
            this.btn_AddAggr.Size = new System.Drawing.Size(81, 22);
            this.btn_AddAggr.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
            this.btn_AddAggr.TabIndex = 1;
            this.btn_AddAggr.Text = "增加统计量";
            this.btn_AddAggr.Click += new System.EventHandler(this.btn_AddAggr_Click);
            // 
            // dataGridViewX1
            // 
            this.dataGridViewX1.AllowUserToAddRows = false;
            this.dataGridViewX1.AllowUserToDeleteRows = false;
            this.dataGridViewX1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
            this.dataGridViewX1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
            this.Column1,
            this.Column2});
            dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
            dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Window;
            dataGridViewCellStyle1.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.ControlText;
            dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight;
            dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.ControlText;
            dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
            this.dataGridViewX1.DefaultCellStyle = dataGridViewCellStyle1;
            this.dataGridViewX1.GridColor = System.Drawing.Color.FromArgb(((int)(((byte)(200)))), ((int)(((byte)(200)))), ((int)(((byte)(200)))));
            this.dataGridViewX1.Location = new System.Drawing.Point(13, 53);
            this.dataGridViewX1.Name = "dataGridViewX1";
            this.dataGridViewX1.RowTemplate.Height = 23;
            this.dataGridViewX1.Size = new System.Drawing.Size(336, 178);
            this.dataGridViewX1.TabIndex = 17;
            // 
            // Column1
            // 
            this.Column1.HeaderText = "统计量";
            this.Column1.Name = "Column1";
            this.Column1.ReadOnly = true;
            // 
            // Column2
            // 
            this.Column2.HeaderText = "统计值";
            this.Column2.Name = "Column2";
            this.Column2.Resizable = System.Windows.Forms.DataGridViewTriState.True;
            this.Column2.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
            // 
            // combo_Aggr
            // 
            this.combo_Aggr.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed;
            this.combo_Aggr.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
            this.combo_Aggr.ForeColor = System.Drawing.Color.Black;
            this.combo_Aggr.FormattingEnabled = true;
            this.combo_Aggr.ItemHeight = 15;
            this.combo_Aggr.Location = new System.Drawing.Point(128, 25);
            this.combo_Aggr.Name = "combo_Aggr";
            this.combo_Aggr.Size = new System.Drawing.Size(94, 21);
            this.combo_Aggr.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
            this.combo_Aggr.TabIndex = 0;
            // 
            // combo_Cols
            // 
            this.combo_Cols.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed;
            this.combo_Cols.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
            this.combo_Cols.ForeColor = System.Drawing.Color.Black;
            this.combo_Cols.FormattingEnabled = true;
            this.combo_Cols.ItemHeight = 15;
            this.combo_Cols.Location = new System.Drawing.Point(13, 24);
            this.combo_Cols.Name = "combo_Cols";
            this.combo_Cols.Size = new System.Drawing.Size(109, 21);
            this.combo_Cols.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
            this.combo_Cols.TabIndex = 18;
            this.combo_Cols.SelectedIndexChanged += new System.EventHandler(this.combo_Cols_SelectedIndexChanged);
            // 
            // tabItem6
            // 
            this.tabItem6.AttachedControl = this.tabControlPanel4;
            this.tabItem6.Name = "tabItem6";
            this.tabItem6.Text = "报表统计（可选）";
            // 
            // btn_PreviewTable
            // 
            this.btn_PreviewTable.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
            this.btn_PreviewTable.Location = new System.Drawing.Point(272, 7);
            this.btn_PreviewTable.Name = "btn_PreviewTable";
            this.btn_PreviewTable.Size = new System.Drawing.Size(105, 24);
            this.btn_PreviewTable.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
            this.btn_PreviewTable.TabIndex = 0;
            this.btn_PreviewTable.Text = "预览字段内容";
            this.btn_PreviewTable.Click += new System.EventHandler(this.btn_PreviewTable_Click);
            // 
            // checkBox3
            // 
            this.checkBox3.AutoSize = true;
            this.checkBox3.BackColor = System.Drawing.Color.Transparent;
            // 
            // 
            // 
            this.checkBox3.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
            this.checkBox3.Location = new System.Drawing.Point(22, 37);
            this.checkBox3.Name = "checkBox3";
            this.checkBox3.Size = new System.Drawing.Size(101, 18);
            this.checkBox3.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
            this.checkBox3.TabIndex = 27;
            this.checkBox3.Text = "打印字段内容";
            // 
            // gb_Settings
            // 
            this.gb_Settings.BackColor = System.Drawing.Color.Transparent;
            this.gb_Settings.CanvasColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))));
            this.gb_Settings.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
            this.gb_Settings.Controls.Add(this.btn_Print);
            this.gb_Settings.Controls.Add(this.btn_PrintSettings);
            this.gb_Settings.Controls.Add(this.btn_PageSettings);
            this.gb_Settings.Controls.Add(this.btn_PrintPreviw);
            this.gb_Settings.DisabledBackColor = System.Drawing.Color.Empty;
            this.gb_Settings.Location = new System.Drawing.Point(383, 61);
            this.gb_Settings.Name = "gb_Settings";
            this.gb_Settings.Size = new System.Drawing.Size(161, 275);
            // 
            // 
            // 
            this.gb_Settings.Style.BackColor2SchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBackground2;
            this.gb_Settings.Style.BackColorGradientAngle = 90;
            this.gb_Settings.Style.BackColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBackground;
            this.gb_Settings.Style.BorderBottom = DevComponents.DotNetBar.eStyleBorderType.Solid;
            this.gb_Settings.Style.BorderBottomWidth = 1;
            this.gb_Settings.Style.BorderColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBorder;
            this.gb_Settings.Style.BorderLeft = DevComponents.DotNetBar.eStyleBorderType.Solid;
            this.gb_Settings.Style.BorderLeftWidth = 1;
            this.gb_Settings.Style.BorderRight = DevComponents.DotNetBar.eStyleBorderType.Solid;
            this.gb_Settings.Style.BorderRightWidth = 1;
            this.gb_Settings.Style.BorderTop = DevComponents.DotNetBar.eStyleBorderType.Solid;
            this.gb_Settings.Style.BorderTopWidth = 1;
            this.gb_Settings.Style.CornerDiameter = 4;
            this.gb_Settings.Style.CornerType = DevComponents.DotNetBar.eCornerType.Rounded;
            this.gb_Settings.Style.TextColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelText;
            this.gb_Settings.Style.TextLineAlignment = DevComponents.DotNetBar.eStyleTextAlignment.Near;
            // 
            // 
            // 
            this.gb_Settings.StyleMouseDown.CornerType = DevComponents.DotNetBar.eCornerType.Square;
            // 
            // 
            // 
            this.gb_Settings.StyleMouseOver.CornerType = DevComponents.DotNetBar.eCornerType.Square;
            this.gb_Settings.TabIndex = 26;
            this.gb_Settings.Text = "打印设置";
            // 
            // btn_Print
            // 
            this.btn_Print.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
            this.btn_Print.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.btn_Print.Image = ((System.Drawing.Image)(resources.GetObject("btn_Print.Image")));
            this.btn_Print.Location = new System.Drawing.Point(16, 201);
            this.btn_Print.Name = "btn_Print";
            this.btn_Print.Size = new System.Drawing.Size(125, 36);
            this.btn_Print.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
            this.btn_Print.TabIndex = 3;
            this.btn_Print.Text = "打    印";
            this.btn_Print.Click += new System.EventHandler(this.btn_Print_Click);
            // 
            // btn_PrintSettings
            // 
            this.btn_PrintSettings.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
            this.btn_PrintSettings.Image = ((System.Drawing.Image)(resources.GetObject("btn_PrintSettings.Image")));
            this.btn_PrintSettings.Location = new System.Drawing.Point(16, 140);
            this.btn_PrintSettings.Name = "btn_PrintSettings";
            this.btn_PrintSettings.Size = new System.Drawing.Size(125, 36);
            this.btn_PrintSettings.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
            this.btn_PrintSettings.TabIndex = 2;
            this.btn_PrintSettings.Text = "打印设置";
            this.btn_PrintSettings.Click += new System.EventHandler(this.btn_PrintSettings_Click);
            // 
            // btn_PageSettings
            // 
            this.btn_PageSettings.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
            this.btn_PageSettings.Image = ((System.Drawing.Image)(resources.GetObject("btn_PageSettings.Image")));
            this.btn_PageSettings.Location = new System.Drawing.Point(16, 79);
            this.btn_PageSettings.Name = "btn_PageSettings";
            this.btn_PageSettings.Size = new System.Drawing.Size(125, 36);
            this.btn_PageSettings.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
            this.btn_PageSettings.TabIndex = 1;
            this.btn_PageSettings.Text = "页面设置";
            this.btn_PageSettings.Click += new System.EventHandler(this.btn_PageSettings_Click);
            // 
            // btn_PrintPreviw
            // 
            this.btn_PrintPreviw.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
            this.btn_PrintPreviw.Image = ((System.Drawing.Image)(resources.GetObject("btn_PrintPreviw.Image")));
            this.btn_PrintPreviw.Location = new System.Drawing.Point(16, 18);
            this.btn_PrintPreviw.Name = "btn_PrintPreviw";
            this.btn_PrintPreviw.Size = new System.Drawing.Size(125, 36);
            this.btn_PrintPreviw.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
            this.btn_PrintPreviw.TabIndex = 0;
            this.btn_PrintPreviw.Text = "打印预览";
            this.btn_PrintPreviw.Click += new System.EventHandler(this.btn_PrintPreviw_Click);
            // 
            // tbReportName
            // 
            this.tbReportName.Location = new System.Drawing.Point(84, 7);
            this.tbReportName.Name = "tbReportName";
            this.tbReportName.Size = new System.Drawing.Size(150, 21);
            this.tbReportName.TabIndex = 1;
            // 
            // label1
            // 
            this.label1.BackColor = System.Drawing.Color.Transparent;
            // 
            // 
            // 
            this.label1.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
            this.label1.Location = new System.Drawing.Point(20, 10);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(77, 18);
            this.label1.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
            this.label1.TabIndex = 21;
            this.label1.Text = "报表名称:";
            // 
            // button_Prev
            // 
            this.button_Prev.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
            this.button_Prev.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
            this.button_Prev.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.button_Prev.Location = new System.Drawing.Point(337, 331);
            this.button_Prev.Name = "button_Prev";
            this.button_Prev.Size = new System.Drawing.Size(77, 25);
            this.button_Prev.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
            this.button_Prev.TabIndex = 21;
            this.button_Prev.Text = "< 上一步";
            this.button_Prev.Visible = false;
            this.button_Prev.Click += new System.EventHandler(this.button_Prev_Click);
            // 
            // btnCancel
            // 
            this.btnCancel.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
            this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
            this.btnCancel.CausesValidation = false;
            this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
            this.btnCancel.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.btnCancel.Location = new System.Drawing.Point(458, 331);
            this.btnCancel.Name = "btnCancel";
            this.btnCancel.Size = new System.Drawing.Size(77, 25);
            this.btnCancel.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
            this.btnCancel.TabIndex = 23;
            this.btnCancel.Text = "退  出";
            this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
            // 
            // tabItem5
            // 
            this.tabItem5.AttachedControl = this.tabControlPanel15;
            this.tabItem5.Name = "tabItem5";
            this.tabItem5.Text = "分组";
            // 
            // tabControlPanel16
            // 
            this.tabControlPanel16.CanvasColor = System.Drawing.SystemColors.Control;
            this.tabControlPanel16.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
            this.tabControlPanel16.Controls.Add(this.combo_FLayer);
            this.tabControlPanel16.Controls.Add(this.btn_Cancel2);
            this.tabControlPanel16.Controls.Add(this.button_Next);
            this.tabControlPanel16.Controls.Add(this.label2);
            this.tabControlPanel16.Controls.Add(this.groupBox5);
            this.tabControlPanel16.DisabledBackColor = System.Drawing.Color.Empty;
            this.tabControlPanel16.Dock = System.Windows.Forms.DockStyle.Fill;
            this.tabControlPanel16.Location = new System.Drawing.Point(0, 25);
            this.tabControlPanel16.Name = "tabControlPanel16";
            this.tabControlPanel16.Padding = new System.Windows.Forms.Padding(1);
            this.tabControlPanel16.Size = new System.Drawing.Size(547, 360);
            this.tabControlPanel16.Style.BackColor1.Color = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))));
            this.tabControlPanel16.Style.Border = DevComponents.DotNetBar.eBorderType.SingleLine;
            this.tabControlPanel16.Style.BorderColor.Color = System.Drawing.Color.FromArgb(((int)(((byte)(204)))), ((int)(((byte)(204)))), ((int)(((byte)(204)))));
            this.tabControlPanel16.Style.BorderSide = ((DevComponents.DotNetBar.eBorderSide)(((DevComponents.DotNetBar.eBorderSide.Left | DevComponents.DotNetBar.eBorderSide.Right) 
            | DevComponents.DotNetBar.eBorderSide.Bottom)));
            this.tabControlPanel16.Style.GradientAngle = 90;
            this.tabControlPanel16.TabIndex = 4;
            this.tabControlPanel16.TabItem = this.tabItem4;
            // 
            // combo_FLayer
            // 
            this.combo_FLayer.BackColor = System.Drawing.SystemColors.Window;
            // 
            // 
            // 
            this.combo_FLayer.BackgroundStyle.Class = "TextBoxBorder";
            this.combo_FLayer.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
            this.combo_FLayer.ButtonDropDown.Visible = true;
            this.combo_FLayer.CompositeLayerEnabled = false;
            this.combo_FLayer.DropDownHeight = 320;
            this.combo_FLayer.DropDownWidth = 300;
            this.combo_FLayer.FeatureType = PlanningGIS.ArcGIS.zjgisFeatureType.Vector;
            this.combo_FLayer.Location = new System.Drawing.Point(78, 7);
            this.combo_FLayer.Name = "combo_FLayer";
            this.combo_FLayer.NodesExpand = null;
            this.combo_FLayer.SelectedLayer = null;
            this.combo_FLayer.Size = new System.Drawing.Size(317, 23);
            this.combo_FLayer.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
            this.combo_FLayer.TabIndex = 45;
            this.combo_FLayer.SelectedIndexChanged += new System.EventHandler(this.combo_FLayer_SelectedIndexChanged);
            // 
            // btn_Cancel2
            // 
            this.btn_Cancel2.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
            this.btn_Cancel2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
            this.btn_Cancel2.BackColor = System.Drawing.Color.Transparent;
            this.btn_Cancel2.CausesValidation = false;
            this.btn_Cancel2.DialogResult = System.Windows.Forms.DialogResult.Cancel;
            this.btn_Cancel2.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.btn_Cancel2.Location = new System.Drawing.Point(458, 331);
            this.btn_Cancel2.Name = "btn_Cancel2";
            this.btn_Cancel2.Size = new System.Drawing.Size(77, 25);
            this.btn_Cancel2.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
            this.btn_Cancel2.TabIndex = 24;
            this.btn_Cancel2.Text = "退  出";
            this.btn_Cancel2.Click += new System.EventHandler(this.btnCancel_Click);
            // 
            // button_Next
            // 
            this.button_Next.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
            this.button_Next.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
            this.button_Next.BackColor = System.Drawing.Color.Transparent;
            this.button_Next.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.button_Next.Location = new System.Drawing.Point(337, 331);
            this.button_Next.Name = "button_Next";
            this.button_Next.Size = new System.Drawing.Size(77, 25);
            this.button_Next.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
            this.button_Next.TabIndex = 22;
            this.button_Next.Text = "下一步 >";
            this.button_Next.Click += new System.EventHandler(this.button_Next_Click);
            // 
            // label2
            // 
            this.label2.AutoSize = true;
            this.label2.BackColor = System.Drawing.Color.Transparent;
            // 
            // 
            // 
            this.label2.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
            this.label2.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.label2.Location = new System.Drawing.Point(16, 12);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(56, 18);
            this.label2.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
            this.label2.TabIndex = 20;
            this.label2.Text = "选择图层";
            // 
            // groupBox5
            // 
            this.groupBox5.BackColor = System.Drawing.Color.Transparent;
            this.groupBox5.CanvasColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))));
            this.groupBox5.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
            this.groupBox5.Controls.Add(this.listSelectCols);
            this.groupBox5.Controls.Add(this.bDel);
            this.groupBox5.Controls.Add(this.bDelOne);
            this.groupBox5.Controls.Add(this.bMove);
            this.groupBox5.Controls.Add(this.bMoveOne);
            this.groupBox5.Controls.Add(this.label10);
            this.groupBox5.Controls.Add(this.label9);
            this.groupBox5.Controls.Add(this.tbSQL);
            this.groupBox5.Controls.Add(this.tvTablesColumns);
            this.groupBox5.DisabledBackColor = System.Drawing.Color.Empty;
            this.groupBox5.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.groupBox5.Location = new System.Drawing.Point(7, 35);
            this.groupBox5.Name = "groupBox5";
            this.groupBox5.Size = new System.Drawing.Size(537, 291);
            // 
            // 
            // 
            this.groupBox5.Style.BackColor2SchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBackground2;
            this.groupBox5.Style.BackColorGradientAngle = 90;
            this.groupBox5.Style.BackColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBackground;
            this.groupBox5.Style.BorderBottom = DevComponents.DotNetBar.eStyleBorderType.Solid;
            this.groupBox5.Style.BorderBottomWidth = 1;
            this.groupBox5.Style.BorderColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBorder;
            this.groupBox5.Style.BorderLeft = DevComponents.DotNetBar.eStyleBorderType.Solid;
            this.groupBox5.Style.BorderLeftWidth = 1;
            this.groupBox5.Style.BorderRight = DevComponents.DotNetBar.eStyleBorderType.Solid;
            this.groupBox5.Style.BorderRightWidth = 1;
            this.groupBox5.Style.BorderTop = DevComponents.DotNetBar.eStyleBorderType.Solid;
            this.groupBox5.Style.BorderTopWidth = 1;
            this.groupBox5.Style.CornerDiameter = 4;
            this.groupBox5.Style.CornerType = DevComponents.DotNetBar.eCornerType.Rounded;
            this.groupBox5.Style.TextColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelText;
            this.groupBox5.Style.TextLineAlignment = DevComponents.DotNetBar.eStyleTextAlignment.Near;
            // 
            // 
            // 
            this.groupBox5.StyleMouseDown.CornerType = DevComponents.DotNetBar.eCornerType.Square;
            // 
            // 
            // 
            this.groupBox5.StyleMouseOver.CornerType = DevComponents.DotNetBar.eCornerType.Square;
            this.groupBox5.TabIndex = 7;
            this.groupBox5.Text = "选择属性字段";
            // 
            // listSelectCols
            // 
            this.listSelectCols.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.listSelectCols.FormattingEnabled = true;
            this.listSelectCols.ItemHeight = 12;
            this.listSelectCols.Location = new System.Drawing.Point(222, 24);
            this.listSelectCols.Name = "listSelectCols";
            this.listSelectCols.Size = new System.Drawing.Size(163, 208);
            this.listSelectCols.TabIndex = 5;
            this.listSelectCols.DoubleClick += new System.EventHandler(this.listSelectCols_DoubleClick);
            // 
            // bDel
            // 
            this.bDel.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
            this.bDel.Location = new System.Drawing.Point(178, 170);
            this.bDel.Name = "bDel";
            this.bDel.Size = new System.Drawing.Size(37, 28);
            this.bDel.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
            this.bDel.TabIndex = 3;
            this.bDel.Text = "<<";
            this.bDel.Click += new System.EventHandler(this.bDel_Click);
            // 
            // bDelOne
            // 
            this.bDelOne.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
            this.bDelOne.Location = new System.Drawing.Point(179, 134);
            this.bDelOne.Name = "bDelOne";
            this.bDelOne.Size = new System.Drawing.Size(37, 28);
            this.bDelOne.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
            this.bDelOne.TabIndex = 2;
            this.bDelOne.Text = "<";
            this.bDelOne.Click += new System.EventHandler(this.bDelOne_Click);
            // 
            // bMove
            // 
            this.bMove.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
            this.bMove.Location = new System.Drawing.Point(178, 83);
            this.bMove.Name = "bMove";
            this.bMove.Size = new System.Drawing.Size(37, 28);
            this.bMove.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
            this.bMove.TabIndex = 1;
            this.bMove.Text = ">>";
            this.bMove.Click += new System.EventHandler(this.bMove_Click);
            // 
            // bMoveOne
            // 
            this.bMoveOne.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
            this.bMoveOne.Location = new System.Drawing.Point(178, 47);
            this.bMoveOne.Name = "bMoveOne";
            this.bMoveOne.Size = new System.Drawing.Size(37, 25);
            this.bMoveOne.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
            this.bMoveOne.TabIndex = 0;
            this.bMoveOne.Text = ">";
            this.bMoveOne.Click += new System.EventHandler(this.bMoveOne_Click);
            // 
            // label10
            // 
            this.label10.AutoSize = true;
            this.label10.BackColor = System.Drawing.Color.Transparent;
            // 
            // 
            // 
            this.label10.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
            this.label10.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.label10.Location = new System.Drawing.Point(220, 6);
            this.label10.Name = "label10";
            this.label10.Size = new System.Drawing.Size(56, 18);
            this.label10.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
            this.label10.TabIndex = 2;
            this.label10.Text = "选定字段";
            // 
            // label9
            // 
            this.label9.AutoSize = true;
            this.label9.BackColor = System.Drawing.Color.Transparent;
            // 
            // 
            // 
            this.label9.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
            this.label9.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.label9.Location = new System.Drawing.Point(8, 6);
            this.label9.Name = "label9";
            this.label9.Size = new System.Drawing.Size(56, 18);
            this.label9.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
            this.label9.TabIndex = 2;
            this.label9.Text = "可用字段";
            // 
            // tbSQL
            // 
            this.tbSQL.AllowDrop = true;
            this.tbSQL.Location = new System.Drawing.Point(292, 113);
            this.tbSQL.Multiline = true;
            this.tbSQL.Name = "tbSQL";
            this.tbSQL.Size = new System.Drawing.Size(63, 26);
            this.tbSQL.TabIndex = 1;
            this.tbSQL.Visible = false;
            this.tbSQL.TextChanged += new System.EventHandler(this.tbSQL_TextChanged);
            // 
            // tvTablesColumns
            // 
            this.tvTablesColumns.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.tvTablesColumns.Location = new System.Drawing.Point(10, 24);
            this.tvTablesColumns.Name = "tvTablesColumns";
            this.tvTablesColumns.Size = new System.Drawing.Size(163, 208);
            this.tvTablesColumns.TabIndex = 6;
            this.tvTablesColumns.DoubleClick += new System.EventHandler(this.tvTablesColumns_DoubleClick);
            // 
            // tabItem4
            // 
            this.tabItem4.AttachedControl = this.tabControlPanel16;
            this.tabItem4.Name = "tabItem4";
            this.tabItem4.Text = "SQL";
            // 
            // tabControlPanel1
            // 
            this.tabControlPanel1.CanvasColor = System.Drawing.SystemColors.Control;
            this.tabControlPanel1.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.Office2000;
            this.tabControlPanel1.DisabledBackColor = System.Drawing.Color.Empty;
            this.tabControlPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
            this.tabControlPanel1.Location = new System.Drawing.Point(0, 25);
            this.tabControlPanel1.Name = "tabControlPanel1";
            this.tabControlPanel1.Padding = new System.Windows.Forms.Padding(1);
            this.tabControlPanel1.Size = new System.Drawing.Size(547, 360);
            this.tabControlPanel1.Style.BackColor1.Color = System.Drawing.Color.FromArgb(((int)(((byte)(142)))), ((int)(((byte)(179)))), ((int)(((byte)(231)))));
            this.tabControlPanel1.Style.BackColor2.Color = System.Drawing.Color.FromArgb(((int)(((byte)(223)))), ((int)(((byte)(237)))), ((int)(((byte)(254)))));
            this.tabControlPanel1.Style.Border = DevComponents.DotNetBar.eBorderType.SingleLine;
            this.tabControlPanel1.Style.BorderColor.Color = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(128)))));
            this.tabControlPanel1.Style.BorderSide = ((DevComponents.DotNetBar.eBorderSide)(((DevComponents.DotNetBar.eBorderSide.Left | DevComponents.DotNetBar.eBorderSide.Right) 
            | DevComponents.DotNetBar.eBorderSide.Bottom)));
            this.tabControlPanel1.Style.GradientAngle = 90;
            this.tabControlPanel1.TabIndex = 8;
            this.tabControlPanel1.TabItem = this.tabItem8;
            // 
            // tabItem8
            // 
            this.tabItem8.AttachedControl = this.tabControlPanel1;
            this.tabItem8.BackColor = System.Drawing.SystemColors.Control;
            this.tabItem8.Name = "tabItem8";
            this.tabItem8.Text = "样式";
            // 
            // tabItem3
            // 
            this.tabItem3.Name = "tabItem3";
            this.tabItem3.Text = "";
            // 
            // tabItem2
            // 
            this.tabItem2.Name = "tabItem2";
            this.tabItem2.Text = "";
            // 
            // tabControlPanel17
            // 
            this.tabControlPanel17.DisabledBackColor = System.Drawing.Color.Empty;
            this.tabControlPanel17.Location = new System.Drawing.Point(0, 0);
            this.tabControlPanel17.Name = "tabControlPanel17";
            this.tabControlPanel17.Padding = new System.Windows.Forms.Padding(1);
            this.tabControlPanel17.Size = new System.Drawing.Size(200, 100);
            this.tabControlPanel17.TabIndex = 0;
            // 
            // printPrevDiag
            // 
            this.printPrevDiag.AutoScrollMargin = new System.Drawing.Size(0, 0);
            this.printPrevDiag.AutoScrollMinSize = new System.Drawing.Size(0, 0);
            this.printPrevDiag.ClientSize = new System.Drawing.Size(400, 300);
            this.printPrevDiag.Enabled = true;
            this.printPrevDiag.Icon = ((System.Drawing.Icon)(resources.GetObject("printPrevDiag.Icon")));
            this.printPrevDiag.Name = "printPrevDiag";
            this.printPrevDiag.Visible = false;
            // 
            // FrmCustomReport
            // 
            this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
            this.ClientSize = new System.Drawing.Size(547, 385);
            this.Controls.Add(this.tcDialog);
            this.DoubleBuffered = true;
            this.EnableGlass = false;
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
            this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
            this.MaximizeBox = false;
            this.MinimizeBox = false;
            this.Name = "FrmCustomReport";
            this.ShowInTaskbar = false;
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
            this.Text = "自定义统计";
            this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmDialogDatabase_FormClosing);
            this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.FrmCustomReport_FormClosed);
            this.Load += new System.EventHandler(this.FrmCustomReport_Load);
            ((System.ComponentModel.ISupportInitialize)(this.tcDialog)).EndInit();
            this.tcDialog.ResumeLayout(false);
            this.tabControlPanel15.ResumeLayout(false);
            this.tabControlPanel15.PerformLayout();
            ((System.ComponentModel.ISupportInitialize)(this.tabControl1)).EndInit();
            this.tabControl1.ResumeLayout(false);
            this.tabControlPanel5.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.sptbctlGeo)).EndInit();
            this.sptbctlGeo.ResumeLayout(false);
            this.superTabControlPanel1.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.barSheet)).EndInit();
            this.superTabControlPanel5.ResumeLayout(false);
            this.superTabControlPanel2.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.regionTree)).EndInit();
            this.tabControlPanel4.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.dataGridViewX1)).EndInit();
            this.gb_Settings.ResumeLayout(false);
            this.tabControlPanel16.ResumeLayout(false);
            this.tabControlPanel16.PerformLayout();
            this.groupBox5.ResumeLayout(false);
            this.groupBox5.PerformLayout();
            this.ResumeLayout(false);

		}
		#endregion


        private void DoGetFilterTable()
        {
            List<string> cols = new List<string>();
            for (int i = 0; i < listSelectCols.Items.Count; i++)
                cols.Add(listSelectCols.Items[i].ToString());

            FilterTable(m_Tab, cols);
        }

		private void DoGrouping()
		{
            if (_ColumnList == null)
                _ColumnList = DesignerUtility.GetSqlColumns(m_FilterTab);

            combo_Cols.Items.Clear();
            foreach (SqlColumn sq in _ColumnList)
            {
                combo_Cols.Items.Add(sq.Name);
            }

            if(combo_Cols.Items.Count > 0)
                combo_Cols.SelectedIndex = 0;

			return;
		}

        private void DoFillReport()
        {
            //dataGridView1.DataSource = m_FilterTab;
        }

		private string GetFieldName(string sqlName)
		{
			StringBuilder sb = new StringBuilder();
			foreach (char c in sqlName)
			{
				if (Char.IsLetterOrDigit(c) || c == '_')
					sb.Append(c);
				else 
					sb.Append('_');
			}
			return sb.ToString();
		}

		private void DoAlignAndCanGrow(Type t, out string canGrow, out string align)
		{
			string st = t.ToString();	
			switch (st)
			{
				case "System.String":
					canGrow="true";
					align="<PaddingLeft>2pt</PaddingLeft>";
					break;
				case "System.Int16":
				case "System.Int32":
				case "System.Single":
				case "System.Double":
				case "System.Decimal":
					canGrow="false";
					align="<PaddingRight>2pt</PaddingRight><TextAlign>Right</TextAlign>";
					break;
				default:
					canGrow="false";
					align="<PaddingLeft>2pt</PaddingLeft>";
					break;
			}
			return;
		}

		private void tvTablesColumns_BeforeExpand(object sender, System.Windows.Forms.TreeViewCancelEventArgs e)
		{
			//tvTablesColumns_ExpandTable(e.Node);
		}

		private void tvTablesColumns_ExpandTable()
		{	
			// Need to obtain the column information for the requested table/view
			// suppress redraw until tree view is complete
			tvTablesColumns.BeginUpdate();

            tvTablesColumns.Nodes.Clear();
            listSelectCols.Items.Clear();
            List<SqlColumn> tColumns = DesignerUtility.GetSqlColumns(m_Tab);
			foreach (SqlColumn sc in tColumns)
			{
                TreeNode tNode = new TreeNode(sc.Name);
                tvTablesColumns.Nodes.Add(sc.Name);
			}

			tvTablesColumns.EndUpdate();
		}

		private void tbSQL_DragEnter(object sender, System.Windows.Forms.DragEventArgs e)
		{
			if (e.Data.GetDataPresent(DataFormats.Text))	// only accept text
				e.Effect = DragDropEffects.Copy;
		}

		private void tbSQL_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
		{
			if (e.Data.GetDataPresent(DataFormats.Text))
				tbSQL.SelectedText = (string) e.Data.GetData(DataFormats.Text);
		}

		private void tvTablesColumns_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
		{
			TreeNode node = tvTablesColumns.GetNodeAt(e.X, e.Y);
			if (node == null || node.Parent == null)
				return; 

			string dragText;
			if (tbSQL.Text == "")
			{
				if (node.Parent.Parent == null)
				{	
					dragText="SELECT ";
					TreeNode next = node.FirstNode;
					while (true)
					{
                        dragText += DesignerUtility.NormalizeSqlName(next.Text);
						next = next.NextNode;
						if (next == null)
							break;
						dragText += ", ";
					}
                    dragText += (" FROM " + DesignerUtility.NormalizeSqlName(node.Text));
				}
				else
				{	// select column; generate select of that column	
                    dragText = "SELECT " + DesignerUtility.NormalizeSqlName(node.Text) + " FROM " + DesignerUtility.NormalizeSqlName(node.Parent.Text);
				}
			}
			else
				dragText = node.Text;

			tvTablesColumns.DoDragDrop(dragText, DragDropEffects.Copy);
		}

		private void tbSQL_TextChanged(object sender, System.EventArgs e)
		{
			_ColumnList=null;			// get rid of any column list as well
			dataGridViewX1.Rows.Clear();
		}

		private void bMove_Click(object sender, System.EventArgs e)
		{
            if (tvTablesColumns.Nodes.Count == 0)
				return;		// this is the Tables/Views node

            listSelectCols.BeginUpdate();
            listSelectCols.Items.Clear();
            for (int i = 0; i < tvTablesColumns.Nodes.Count; i++)
            {
                listSelectCols.Items.Add(tvTablesColumns.Nodes[i].Text);
            }
            listSelectCols.EndUpdate();
            GetSQL();
            if (listSelectCols.Items.Count > 0) button_Next.Enabled = true;
            else button_Next.Enabled = false;
		}

		private void bValidValues_Click(object sender, System.EventArgs e)
		{
		}

        private void button_Next_Click(object sender, EventArgs e)
        {
            if (tcDialog.SelectedTab.Text == "SQL")
            {
                if (tbSQL.Text.Trim().Length == 0)
                {
                    MsgHelper.ShowInfomationMsgbox("请先选定字段");
                    return;
                }

                tcDialog.SelectedTab = tabItem5;
                Application.DoEvents();
                DoGetFilterTable();
                DoGrouping();
                GetPrintEngine();

                pagedGrid.Turnpage = TurnPage;
                pagedGrid.GetGridView().AllowUserToResizeColumns = true;
                pagedGrid.GetGridView().AllowUserToResizeRows = true;
                FillFilterTable((ITable)_pFeatClass);
            }
            else if (tcDialog.SelectedTab.Text == "分组")
            {
                tcDialog.SelectedTab = tabItem8;
            }
            else if (tcDialog.SelectedTab.Text == "样式")
            {
                
            }
        }

        private void button_Prev_Click(object sender, EventArgs e)
        {
            if (tcDialog.SelectedTab.Text == "SQL")
            {

            }
            else if (tcDialog.SelectedTab.Text == "分组")
            {
                tcDialog.SelectedTab = tabItem4;
            }
            else if (tcDialog.SelectedTab.Text == "样式")
            {
                tcDialog.SelectedTab = tabItem8;
            }
        }

        private void tabControl1_SelectedIndexChanged(object sender, DevComponents.DotNetBar.TabStripTabChangedEventArgs e)
        {
            DevComponents.DotNetBar.TabControl tc = (DevComponents.DotNetBar.TabControl)sender;
            string strText = (string)tc.SelectedTab.Text;
            
            switch (strText)
            {
                case "SQL":		// obtain table and column information
                    button_Prev.Visible = false;
                    button_Next.Visible = true;
                    break;
                case "分组":	// obtain group by information using connection & sql
                    button_Prev.Visible = true;
                    button_Next.Visible = false;
                    
                    break;
                case "样式":	// obtain report using connection, sql, 
                    DoFillReport();
                    this.btnCancel.Text = "关闭";
                    this.button_Prev.Visible = false;
                    this.button_Next.Visible = false;
                    break;
                default:
                    break;
            }
        }

        private void tvTablesColumns_DoubleClick(object sender, EventArgs e)
        {
            bMoveOne_Click(null, null);
        }

        private void bMoveOne_Click(object sender, EventArgs e)
        {
            if (tvTablesColumns.SelectedNode == null)
                return;
            if (tvTablesColumns.SelectedNode.Text.Trim() == "")
                return;
            for (int i = 0; i < listSelectCols.Items.Count; i++)
            {
                if (listSelectCols.Items[i].ToString() == tvTablesColumns.SelectedNode.Text)
                    return;
            }

            listSelectCols.Items.Add(tvTablesColumns.SelectedNode.Text);
            if (listSelectCols.Items.Count > 0) button_Next.Enabled = true;
            else button_Next.Enabled = false;
            GetSQL();
        }

        private void bDelOne_Click(object sender, EventArgs e)
        {
            if (listSelectCols.SelectedIndex == -1)
                return;
            listSelectCols.BeginUpdate();
            listSelectCols.Items.RemoveAt(listSelectCols.SelectedIndex);
            GetSQL();
            listSelectCols.EndUpdate();
            if (listSelectCols.Items.Count > 0) button_Next.Enabled = true;
            else button_Next.Enabled = false;
        }

        private void bDel_Click(object sender, EventArgs e)
        {
            listSelectCols.BeginUpdate();
            listSelectCols.Items.Clear();
            GetSQL();
            listSelectCols.EndUpdate();
            if (listSelectCols.Items.Count > 0) button_Next.Enabled = true;
            else button_Next.Enabled = false;
        }

        private void listSelectCols_DoubleClick(object sender, EventArgs e)
        {
            bDelOne_Click(null, null);
        }

        private void GetSQL()
        {
            String t;
            if (listSelectCols.Items.Count > 0)
            {
                // select column
                StringBuilder sb = new StringBuilder("SELECT ");
                for(int i=0; i<listSelectCols.Items.Count; i++)
                {
                    if (listSelectCols.Items[i].ToString().ToLower() != "shape")
                    {
                        sb.Append(DesignerUtility.NormalizeSqlName(listSelectCols.Items[i].ToString()));
                        if (i < listSelectCols.Items.Count - 1)
                            sb.Append(", ");
                    }
                }
                
                sb.Append(" FROM ");
                sb.Append(DesignerUtility.NormalizeSqlName(tbReportName.Text));
                t = sb.ToString();
            }
            else
            {	
                // select column; generate select of that column	
                StringBuilder sb = new StringBuilder("SELECT ");
                for (int i = 0; i < tvTablesColumns.Nodes.Count; i++)
                {
                    if (tvTablesColumns.Nodes[i].ToString().ToLower() != "shape")
                    {
                        sb.Append(DesignerUtility.NormalizeSqlName(tvTablesColumns.Nodes[i].ToString()));
                        if (i < tvTablesColumns.Nodes.Count - 1)
                            sb.Append(", ");
                    }
                }

                sb.Append(" FROM ");
                sb.Append(DesignerUtility.NormalizeSqlName(tbReportName.Text));
                t = sb.ToString();
            }

            tbSQL.Text = t;
        }

        private static void GetSubFeatureLayer(ILayer pLayer, ref List<IFeatureLayer> allMapLayer)
        {
            if (pLayer.Valid == false) return;
            ICompositeLayer pCompositeLayer;
            if (pLayer is IGroupLayer)
            {
                pCompositeLayer = pLayer as ICompositeLayer;
                for (int i = 0; i < pCompositeLayer.Count; i++)
                {
                    if (pCompositeLayer.get_Layer(i) is IGroupLayer)
                    {
                        GetSubFeatureLayer(pCompositeLayer.get_Layer(i), ref allMapLayer);
                    }
                    else if (pCompositeLayer.get_Layer(i) is IFeatureLayer)
                    {
                        allMapLayer.Add(pCompositeLayer.get_Layer(i) as IFeatureLayer);
                    }
                }
            }
            else
            {
                if (pLayer is IFeatureLayer)
                {
                    allMapLayer.Add(pLayer as IFeatureLayer);
                }
            }
        }

        /// <summary>
        /// 自定义范围控件画完之后调用的事件
        /// </summary>
        /// <param name="pGeom"></param>
        /// <param name="shift"></param>
        private void AfterButtonOkEvent(IGeometry pGeom, int shift)
        {
            if (pGeom == null || pGeom.IsEmpty || pGeom is IPoint)
            {
                return;
            }
            try
            {
                if (pGeom is IEnvelope)
                {
                    pGeom = ((IEnvelope)pGeom).ToPolygon();
                }
                else if (pGeom is ICircularArc)
                {
                    IPolygon pPolygon = new PolygonClass();
                    ISegmentCollection pSegCollection = pPolygon as ISegmentCollection;
                    object missing = System.Type.Missing;
                    pSegCollection.AddSegment(pGeom as ISegment, ref missing, ref missing);
                    pPolygon.SpatialReference = pGeom.SpatialReference;
                    pGeom = pPolygon;
                }

                if (pGeom == null || pGeom.IsEmpty) return;

                Cursor = Cursors.Default;

                pPolygonCustom = pGeom as IPolygon;
                GeometryUserDraw(pPolygonCustom);
            }
            catch (System.Exception)
            {

            }
            finally
            {
                this.WindowState = FormWindowState.Normal;
            }

        }

        /// <summary>
        /// 画用户权限内的范围
        /// </summary>
        /// <param name="pPolyUserDraw"></param>
        private void GeometryUserDraw(IPolygon pPolyUserDraw)
        {
            if (pPolyUserDraw == null || pPolyUserDraw.IsEmpty) return; ;
            IPolyline pPolyline = pPolyUserDraw.ToPolyline();

            IRgbColor pRgbColor = new RgbColorClass();
            pRgbColor.Red = 255;
            pRgbColor.Green = 155;
            pRgbColor.Blue = 0;

            IActiveView pActiveView = (m_Application.Document as IMxDocument).ActiveView;
            IGraphicsContainer pGeoContainer = pActiveView as IGraphicsContainer;
            if (m_pElementUserDraw != null)
                try
                {
                    pGeoContainer.DeleteElement(m_pElementUserDraw);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }

            ISimpleLineSymbol pLineSymbol = new SimpleLineSymbolClass();
            ILineElement pLineElement = new LineElementClass();
            pLineSymbol.Style = esriSimpleLineStyle.esriSLSSolid;
            pLineSymbol.Color = pRgbColor;
            pLineSymbol.Width = 3;
            pLineElement.Symbol = pLineSymbol;
            m_pElementUserDraw = pLineElement as IElement;
            m_pElementUserDraw.Geometry = pPolyline;
            pGeoContainer.AddElement(m_pElementUserDraw, 0);
            pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, pActiveView.Extent);
        }

        private void FrmCustomReport_Load(object sender, EventArgs e)
        {
            //图幅选择控件赋控制器
            //IHookHelper m_HookHelp = new HookHelperExClass();
            //m_HookHelp.Hook = m_Application;
            //chooseTuFu1.HookHelper = m_HookHelp;
            //selectFWX1.HookHelper = m_HookHelp;
            //selectFWX1.selectAreaControl1.afterButtonOkShift1 += new AfterButtonOkShift(AfterButtonOkEvent);
            //selectXZQ1.HookHelper = m_HookHelp;

            combo_FLayer.FeatureType = zjgisFeatureType.Vector;            
            combo_FLayer.OnCreate((m_Application as IFramework).Object);
            button_Next.Enabled = false;
            Init();
            AddPageGrid();
        }

        /// <summary>
        /// 初始化对象
        /// </summary>
        private void Init()
        {
            _SheetCreator = new SheetCreator(spgrdSheet, false);
            _SheetCreator.Hook = m_HookHelp.Hook;
            _SheetCreator.IsToMap = true;


            List<ValueName> btns = new List<ValueName>()
            {
                new ValueName(){Value="ToolDrawRectangle",Name="绘制矩形"},
                new ValueName(){Value="ToolDrawPolygon",Name="绘制多边形"},
                new ValueName(){Value="ToolDrawCircle",Name="绘制圆"},
                new ValueName(){Value="ToolDrawLine",Name="绘制线"}
            };
            _ToolCreator = new ToolCreator(btnDrawExtent, m_HookHelp.Hook);
            _ToolCreator.HideForm = true;
            _ToolCreator.Create(btns, true);
            _ToolCreator.DrawFinished += OnDrawFinished;
            regionTree.Hook = m_HookHelp.Hook;
            if (JHBHelper.ScaleValues != null)
            {
                foreach (int scale in JHBHelper.ScaleValues)
                {
                    this.cmbScale.Items.Add(scale.ToString());
                }
            }
            if (cmbScale.Items.Count > 0)
            {
                this.cmbScale.SelectedIndex = 0;
            }
        }

        /// <summary>
        /// 绘制完成
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void OnDrawFinished(object sender, DrawArgs e)
        {
            if (sptbctlGeo.SelectedTab == sptbitmRegion)
                regionTree.SelectRegion(e.Geometry, e.Shift);
            else if (sptbctlGeo.SelectedTab == sptbitmSheet)
                _SheetCreator.SelectRegion(e.Geometry, e.Shift);

        }

        public object GetUVByQueryDef(IFeatureClass pFeatCls, String strField, string AggrFuntion)
        {
            ICursor pCursor;
            IDataset pDataset = pFeatCls as IDataset;
            IFeatureWorkspace pFeatureWorkspace = pDataset.Workspace as IFeatureWorkspace;
            IQueryDef pQueryDef = pFeatureWorkspace.CreateQueryDef();
            pQueryDef.Tables = pDataset.Name;           // Fully qualified table name
            pQueryDef.SubFields = AggrFuntion + " (" + strField + ")";
            pCursor = pQueryDef.Evaluate();

            IRow pRow = pCursor.NextRow();
            object obj = pRow.get_Value(0);

            Marshal.ReleaseComObject(pCursor);
            return obj;
        }

        /// <summary>
        /// 计算唯一值
        /// 通过IQueryDef接口使用类似SQL的查询语句来获取图层字段的唯一值集合，执行速度等同于执行SQL查询语句
        /// 对于数据量大的，大大优化
        /// </summary>
        /// <param name="pFeatCls"></param>
        /// <param name="strField"></param>
        /// <returns></returns>
        public int GetUVByQueryDef(IFeatureClass pFeatCls, String strField)
        {            
            IDataset pDataset = pFeatCls as IDataset;
            IFeatureWorkspace pFeatureWorkspace = pDataset.Workspace as IFeatureWorkspace;
            IQueryDef pQueryDef = pFeatureWorkspace.CreateQueryDef();
            pQueryDef.Tables = pDataset.Name;           // Fully qualified table name

            //IQueryFilter pQueryFilter = new QueryFilterClass();
            pQueryDef.SubFields = "Distinct (" + strField + ")";
            ICursor pCursor = pQueryDef.Evaluate();
            //int ind = pFeatCls.FindField(strField);
            pQueryDef.Evaluate();
            //IFeatureCursor pFeatureCursor = this._pFeatClass.Search(pQueryFilter, false);

            int Count = 0;
            //while (pFeatureCursor.NextFeature() != null)
            while (pCursor.NextRow() != null)
            {
                Count++;
            }

            Marshal.ReleaseComObject(pCursor);
            return Count;
        }

        /// <summary>
        /// 计算pFeatCls某属性字段的统计量
        /// </summary>
        /// <param name="pFeatCls"></param>
        /// <param name="rowname"></param>
        /// <param name="AggrFuntion"></param>
        /// <returns></returns>
        private object Evaluate(IFeatureClass pFeatCls, string rowname, string AggrFuntion,IGeometry pGeometry)
        {
            ISpatialFilter pFilter = new SpatialFilterClass();
            pFilter.GeometryField = pFeatCls.ShapeFieldName;
            pFilter.Geometry = pGeometry;
            pFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;

            FeatureCount = pFeatCls.FeatureCount(pFilter);

            if (AggrFuntion == "Count")
                return  FeatureCount;
            else if (AggrFuntion == "CountDistinct")
            {
                IDataStatistics pDataStat = new DataStatisticsClass();
                pDataStat.Field = rowname;
                pDataStat.Cursor = pFeatCls.Search(pFilter, false) as ICursor;
                IEnumerator pEnumVar = pDataStat.UniqueValues;
                return pDataStat.UniqueValueCount;
                //return GetUVByQueryDef(pFeatCls, rowname);
            }

            if (FeatureCount > 50000)
            {
                if (MsgHelper.ShowYesOrNoQueryMsgBox("图层要素记录超过50000个，统计会花很长时间，您确定要统计该项吗？") == DialogResult.No)
                    return null;
            }

            object oRtn = null;
            try
            {
                IFeatureCursor pFeatCur = pFeatCls.Search(pFilter, true);
                IDataStatistics dataStatistics = new DataStatisticsClass();
                dataStatistics.Field = rowname;
                dataStatistics.Cursor = pFeatCur as ICursor;

                IStatisticsResults statisticsResults = dataStatistics.Statistics;

                if (AggrFuntion == "Sum")
                    oRtn = statisticsResults.Sum.ToString("#.###");
                else if (AggrFuntion == "Avg")
                    oRtn = (statisticsResults.Sum / FeatureCount).ToString("#.###");
                else if (AggrFuntion == "Min")
                    oRtn = statisticsResults.Minimum.ToString("#.###");
                else if (AggrFuntion == "Max")
                    oRtn = statisticsResults.Maximum.ToString("#.###");
                else if (AggrFuntion == "Stdev")
                    oRtn = statisticsResults.StandardDeviation.ToString("#.###");
                else if (AggrFuntion == "Varp")
                {
                    double stddev = statisticsResults.StandardDeviation;
                    oRtn = (stddev * stddev).ToString("#.###");
                }

                Marshal.ReleaseComObject(pFeatCur);
            }
            catch (Exception ce)
            {
                MsgHelper.ShowErrorMsgbox("统计出错，请检查下数据。");
            }

            return oRtn;
        }

        private object Evaluate(DataTable view, string rowname, string AggrFuntion)
        {
            int index = 0;
            for (int i = 0; i < view.Columns.Count; i++)
            {
                if (view.Columns[i].ColumnName == rowname)
                {
                    index = i;
                    break;
                }
            }
 
            object v;
            if (AggrFuntion == "Count")
                return view.Rows.Count;
            else if (AggrFuntion == "CountDistinct")
            {
                List<String> ValueList = new List<string>();
                String strValue = "";
                for (int i = 0; i < view.Rows.Count; i++)
                {
                    v = view.Rows[i].ItemArray[index];
                    if (v == null)
                        break;
                    else
                    {
                        strValue = Convert.ToString(v);
                        int j  = 0;
                        for (j= 0; j < ValueList.Count; j++)
                        {
                            if (strValue == ValueList[j]) break;
                            
                        }

                        if(j == ValueList.Count)
                            ValueList.Add(strValue);
                    }
                }
                return ValueList.Count;
            }
            else if (AggrFuntion == "Sum")
            {
                double Ret = 0;
                for (int i = 0; i < view.Rows.Count; i++)
                {
                    v = view.Rows[i].ItemArray[index];
                    if (v == null)
                        break;
                    else
                    {
                        Ret += Convert.ToDouble(v);
                    }
                }
                return Ret;
            }
            else if (AggrFuntion == "Avg")
            {
                double Ret = 0;
                int Count = 0;
                for (int i = 0; i < view.Rows.Count; i++)
                {

                    v = view.Rows[i].ItemArray[index];
                    if (v == null)
                        continue;
                    else
                    {
                        Count++;
                        Ret += Convert.ToDouble(v);
                    }
                }
                return Ret / Count;
            }
            else if (AggrFuntion == "Min")
            {
                object min_value = null;
                for (int i = 0; i < view.Rows.Count; i++)
                {
                    v = view.Rows[i].ItemArray[index];
                    if (v == null)
                        continue;
                    else if (min_value == null)
                        min_value = v;
                    else if (Convert.ToDouble(v) < Convert.ToDouble(min_value))
                        min_value = Convert.ToDouble(v);

                }
                return min_value;
            }
            else if (AggrFuntion == "Max")
            {
                object max_value = null;
                for (int i = 0; i < view.Rows.Count; i++)
                {
                    v = view.Rows[i].ItemArray[index];
                    if (v == null)
                        continue;
                    else if (max_value == null)
                        max_value = v;
                    else if (Convert.ToDouble(v) > Convert.ToDouble(max_value))
                        max_value = Convert.ToDouble(v);

                }
                return max_value;
            }
            else if (AggrFuntion == "Stdev")
            {
                double sum = 0;
                double sum2 = 0;
                int count = 0;
                double temp;
                for (int i = 0; i < view.Rows.Count; i++)
                {
                    temp = Convert.ToDouble(v = view.Rows[i].ItemArray[index]);
                    if (temp.CompareTo(double.NaN) != 0)
                    {
                        sum += temp;
                        sum2 += (temp * temp);
                        count++;
                    }
                }

                double result;
                if (count > 1)
                {
                    result = Math.Sqrt((count * sum2 - sum * sum) / (count * (count - 1)));
                }
                else
                    result = double.NaN;
                return result;
            }
            else if (AggrFuntion == "Stdevp")
            {
                double sum = 0;
                double sum2 = 0;
                int count = 0;
                double temp;
                for (int i = 0; i < view.Rows.Count; i++)
                {
                    temp = Convert.ToDouble(v = view.Rows[i].ItemArray[index]);
                    if (temp.CompareTo(double.NaN) != 0)
                    {
                        sum += temp;
                        sum2 += (temp * temp);
                        count++;
                    }
                }

                double result;
                if (count > 1)
                {
                    result = Math.Sqrt((count * sum2 - sum * sum) / (count * count));
                }
                else
                    result = double.NaN;
                return result;
            }
            else if (AggrFuntion == "Varp")
            {
                double sum = 0;
                double sum2 = 0;
                int count = 0;
                double temp;
                for (int i = 0; i < view.Rows.Count; i++)
                {
                    temp = Convert.ToDouble(v = view.Rows[i].ItemArray[index]);
                    if (temp.CompareTo(double.NaN) != 0)
                    {
                        sum += temp;
                        sum2 += (temp * temp);
                        count++;
                    }
                }

                double result;
                if (count > 1)
                {
                    result = (count * sum2 - sum * sum) / (count * count);
                }
                else
                    result = double.NaN;
                return result;
            }

            return null;
        }

        static private String[] AggrFuntionList = new String[]
        {
            "总和", "Sum",
            "平均值","Avg",
            "最小值","Min",
            "最大值","Max",
            "记录数","Count",
            "唯一值个数","CountDistinct",
            "标准差","Stdev",
            "总方差","Varp",
        };

        static private String[] AggrFuntionList2 = new String[]
        {
            "记录数","Count",
            "唯一值个数","CountDistinct",
        };

        private void btnCancel_Click(object sender, EventArgs e)
        {
            if (btnCancel.Text == "关闭")
            {
                btnCancel.Text = "退出";
                this.Text = "创建统计报表";
                tcDialog.SelectedTab = tabItem5;
                this.button_Prev.Visible = true;
                this.button_Next.Visible = false;
            }
            else
            {
                Close(); }
        }

        private void btn_PrintPreviw_Click(object sender, EventArgs e)
        {
            ResetPeport();
            PrintPreviewDialog ppd = new PrintPreviewDialog();
            ppd.Document = this.objRepLib.ReportPrintDocument;
            ppd.Icon = this.Icon;
            ppd.StartPosition = FormStartPosition.CenterScreen;
            ppd.WindowState = FormWindowState.Maximized;
            ppd.Show(this);
        }

        private void btn_PageSettings_Click(object sender, EventArgs e)
        {
            PageSetupDialog psd = new PageSetupDialog();
            psd.Document = this.objRepLib.ReportPrintDocument;
            if (psd.ShowDialog(this) == DialogResult.OK)
            {
                this.objRepLib.ReportPrintDocument.DefaultPageSettings.Margins = new Margins(Convert.ToInt32(psd.PageSettings.Margins.Left * 2.54), Convert.ToInt32(psd.PageSettings.Margins.Right * 2.54), Convert.ToInt32(psd.PageSettings.Margins.Top * 2.54), Convert.ToInt32(psd.PageSettings.Margins.Bottom * 2.54));
            }
        }

        private void btn_PrintSettings_Click(object sender, EventArgs e)
        {
            PrintDialog psd = new PrintDialog();
            psd.Document = this.objRepLib.ReportPrintDocument;
            psd.AllowSomePages = false;
            psd.ShowDialog(this);
        }

        private void btn_Print_Click(object sender, EventArgs e)
        {
            ResetPeport();
            try
            {
                
                this.objRepLib.ReportPrintDocument.Print();
            }
            catch (Exception ex)
            {
                MsgHelper.ShowErrorMsgbox("打印出错，出错信息是:" + ex.Message + " 请检查打印设置！");
            }
        }

        /// <summary>
        /// 根据当前所选内容，重新设置打印内容
        /// </summary>
        private void ResetPeport()
        {
            this.objRepLib.AggrTexts.Clear();
            String ColName = "";
            String AggrValue = "";
            for (int i = 0; i < dataGridViewX1.Rows.Count; i++)
            {
                ColName = dataGridViewX1.Rows[i].Cells[0].Value.ToString();
                AggrValue = dataGridViewX1.Rows[i].Cells[1].Value.ToString();
                
                this.objRepLib.AggrTexts.Add(ColName.Trim());
                this.objRepLib.AggrTexts.Add(AggrValue);
            }
            objRepLib.IsDrawTable = checkBox3.Checked;
            if (tbReportName.Text.Trim().Length == 0)
            {
                objRepLib.HasTitle = false;
            }
            else
            {
                objRepLib.HasTitle = true;
                objRepLib.ReportTitle = tbReportName.Text;
            }

            List<int> _ColWidths = new List<int>();
            if (pagedGrid.GetGridView().Columns.Count > 0)
            {
                foreach (DataGridViewColumn col in pagedGrid.GetGridView().Columns)
                {
                    _ColWidths.Add(col.Width);
                }
            }
            else
            {
                foreach (DataColumn col in this.m_FilterTab.Columns)
                {
                    _ColWidths.Add(col.ColumnName.Length * 8 + 24);
                }
            }

            objRepLib.HideGrid = false;
            objRepLib.ReportTitle = tbReportName.Text;
            objRepLib.HeaderRowHeight = pagedGrid.GetGridView().ColumnHeadersHeight;
            objRepLib.ColWidths = _ColWidths;
            objRepLib.ReportSource = m_FilterTab;

            if (pagedGrid.GetGridView().Rows.Count > 0)
            {
                objRepLib.RowHeight = pagedGrid.GetGridView().Rows[0].Height;
            }
            else
            {
                objRepLib.RowHeight = 24;
            }
        }

        /// <summary>
        /// 初始化打印内容
        /// </summary>
        private void GetPrintEngine()
        {
            DataTable dt = m_FilterTab;

            objRepLib.ReportSource = dt;
            
            objRepLib.ReportTitleFirstPageOnly = true;
            objRepLib.ReportHasLogo = false;

            objRepLib.HasTitle = true;
            objRepLib.ReportShowTotals = false;
            objRepLib.IsLandscape = false;
        }

        private void combo_Cols_SelectedIndexChanged(object sender, EventArgs e)
        {
            DataTable tab = new DataTable();
            tab.Columns.Add("Text");
            tab.Columns.Add("Value");
            for (int i = 0; i < AggrFuntionList.Length / 2; i++)
            {
                DataRow row = tab.NewRow();
                row[0] = AggrFuntionList[i * 2];
                row[1] = AggrFuntionList[i * 2 + 1];
                tab.Rows.Add(row);
            }

            DataTable tab2 = new DataTable();
            tab2.Columns.Add("Text");
            tab2.Columns.Add("Value");
            for (int i = 0; i < AggrFuntionList2.Length / 2; i++)
            {
                DataRow row = tab2.NewRow();
                row[0] = AggrFuntionList2[i * 2];
                row[1] = AggrFuntionList2[i * 2 + 1];
                tab2.Rows.Add(row);
            }

            SqlColumn sq = _ColumnList[combo_Cols.SelectedIndex];
            if (DesignerUtility.IsNumeric(sq.DataType))
                combo_Aggr.DataSource = tab;
            else
                combo_Aggr.DataSource = tab2;

            combo_Aggr.DisplayMember = "Text";
            combo_Aggr.ValueMember = "Value";
            if (combo_Aggr.Items.Count > 0)
            {
                combo_Aggr.SelectedIndex = 0;
            }
        }

        private void btn_AddAggr_Click(object sender, EventArgs e)
        {
            try
            {
                if ((combo_Cols.Text.Trim() != "") && (combo_Aggr.SelectedValue.ToString().Trim() != ""))
                {
                    object oRtn = null;
                    if (chkUseCstExt.Checked)
                    {
                        switch (sptbctlGeo.SelectedTab.Text)
                        {
                            case "图幅": //按图幅导出
                                pPolygonSurvey = (IPolygon)_SheetCreator.GetSelectGeometry();
                                break;
                            case "自定义范围": //按自定义范围
                                pPolygonSurvey = (IPolygon)_ToolCreator.Geometry;
                                break;                                

                            case "行政区":
                                pPolygonSurvey = (IPolygon)regionTree.SelectedGeometry;
                                break;

                            default:
                                return;
                        }

                        oRtn = Evaluate(_pFeatClass, combo_Cols.Text, combo_Aggr.SelectedValue.ToString(), pPolygonSurvey);
                    }
                    else
                    {

                        oRtn = Evaluate(_pFeatClass, combo_Cols.Text, combo_Aggr.SelectedValue.ToString(), null);
                    }
                    if (oRtn != null)
                        dataGridViewX1.Rows.Add(combo_Cols.Text + " " + combo_Aggr.Text, oRtn);
                }
            }
            catch (Exception ex)
            {
            }
        }

        private void btn_PreviewTable_Click(object sender, EventArgs e)
        {
            //pagedGrid.ResetDataSource((uint)FeatureCount);
            
            tcDialog.SelectedTab = tabItem8;
            this.Text = "预览表内容";
            //dataGridView1.Top = combo_RowCount.Bottom + 5;
        }

        private void FrmDialogDatabase_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (btnCancel.Text == "关闭")
            {
                e.Cancel = true;    //取消关闭
                btnCancel.Text = "退出";
                this.Text = "创建统计报表";
                tcDialog.SelectedTab = tabItem5;
                this.button_Prev.Visible = true;
                this.button_Next.Visible = false;
            }

            //(m_Application as IFramework).Tool = null;
            //chooseTuFu1.ClearElements();
            ////chooseXZQ1.ClearElements();

            //IActiveView pAV = (m_Application.Document as IMxDocument).ActiveView;

            //IGraphicsContainer pGeoContainer = pAV as IGraphicsContainer;

            //if (m_pElementUserDraw != null)
            //    try
            //    {
            //        pGeoContainer.DeleteElement(m_pElementUserDraw);
            //        //IActiveView pAV = ((AxMapControl)statusController.Host).ActiveView;
            //        pAV.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, pAV.Extent);
            //    }
            //    catch (Exception ex)
            //    {
            //        Console.WriteLine(ex.Message);
            //    }
        }

        private void combo_FLayer_SelectedIndexChanged(object sender, EventArgs e)
        {
            List<IFeatureLayer> pFeatLayers = new List<IFeatureLayer>();
            IEnumLayer layers = m_pMapCtl.Map.get_Layers(null, true);
            ILayer layer = layers.Next();
            while (layer != null)
            {
                if (layer.Valid && (layer is IFeatureLayer))
                {
                    pFeatLayers.Add(layer as IFeatureLayer);
                }
                layer = layers.Next();
            }

            for (int i = 0; i < pFeatLayers.Count; i++)
            {
                if (combo_FLayer.Text == pFeatLayers[i].Name)
                {
                    _pFeatClass = pFeatLayers[i].FeatureClass;
                    m_Tab = CreateDTFrameFromITable((ITable)_pFeatClass, _pFeatClass.AliasName);
                    tbReportName.Text = _pFeatClass.AliasName;
                    tvTablesColumns_ExpandTable();
                    return;
                }
            }

            MsgHelper.ShowWarningMsgbox("图层" + combo_FLayer.Text + "已卸载");
        }

        /*
        private void combo_RowCount_TextChanged(object sender, EventArgs e)
        {
            int RowCount = 0;
            if (combo_RowCount.Text == "所有行")
            {
                RowCount = FeatureCount;
            }
            else
            {
                RowCount = Convert.ToInt32(combo_RowCount.Text);
            }

            try
            {
                IQueryFilter que = new QueryFilterClass();
                ICursor pCursor = (ICursor)_pFeatClass.Search(que, false);
                IRow pRow = pCursor.NextRow();
                int totalCount = 0;

                if (pRow != null)
                {
                    m_FilterTab.Rows.Clear();
                    List<int> FieldIndexList = new List<int>();
                    for (int k = 0; k < m_FilterTab.Columns.Count; k++)
                    {
                        for (int i = 0; i < pRow.Fields.FieldCount; i++)
                        {
                            if (pRow.Fields.get_Field(i).Name == m_FilterTab.Columns[k].ColumnName)
                            {
                                FieldIndexList.Add(i);
                                break;
                            }
                        }
                    }
                    while ((pRow != null) && (totalCount < RowCount))
                    {
                        totalCount++;
                        //if (totalCount % 5000 == 0) System.Windows.Forms.Application.DoEvents();

                        DataRow pDataRow = m_FilterTab.NewRow();

                        for (int k = 0; k < m_FilterTab.Columns.Count; k++)
                        {
                            pDataRow[k] = pRow.get_Value(FieldIndexList[k]);
                        }
                        m_FilterTab.Rows.Add(pDataRow);
                        pRow = pCursor.NextRow();
                    }
                }

                Marshal.ReleaseComObject(pCursor);
            }
            catch (System.Exception ex)
            {
                PlanningGIS.ADF.BaseClasses.ControlUtility.ShowErrorMsgbox(ex.Message, "自定义统计");
                return;
            }

            dataGridView1.DataSource = m_FilterTab;
        }*/

        private DataTable GetDatum(int from, int to)
        {
            IQueryFilter qfilter = new QueryFilterClass();
            if (orderby() != null && orderby() != "")
            {
                IQueryFilterDefinition def = qfilter as IQueryFilterDefinition;
                def.PostfixClause = orderby();
            }

            try
            {
                IFeatureCursor featureCursor = _pFeatClass.Search(qfilter, false);
                IFeature feature = featureCursor.NextFeature();
                int totalCount = 0;

                    m_FilterTab.Rows.Clear();
                    List<int> FieldIndexList = new List<int>();
                    for (int k = 0; k < m_FilterTab.Columns.Count; k++)
                    {
                        for (int i = 0; i < feature.Fields.FieldCount; i++)
                        {
                            if (feature.Fields.get_Field(i).Name == m_FilterTab.Columns[k].ColumnName)
                            {
                                FieldIndexList.Add(i);
                                break;
                            }
                        }
                    }
                    while (feature != null)
                    {
                        if (totalCount > to)
                        {
                            break;
                        }
                        else if (totalCount >= from)
                        {
                            DataRow pDataRow = m_FilterTab.NewRow();

                            for (int k = 0; k < m_FilterTab.Columns.Count; k++)
                            {
                                pDataRow[k] = feature.get_Value(FieldIndexList[k]);
                            }
                            m_FilterTab.Rows.Add(pDataRow);
                        }
                        totalCount++;
                        feature = featureCursor.NextFeature();
                    }

                    Marshal.ReleaseComObject(featureCursor);
            }
            catch (System.Exception ex)
            {
                MsgHelper.ShowErrorMsgbox("自定义统计出错:" + ex.Message);
                return null;
            }

            //pagedGrid.GetGridView().DataSource = m_FilterTab;
            //dataGridView1.DataSource = m_FilterTab;
            return m_FilterTab;
        }

        private string whereclause;
        private string orderby()
        {
            return (pagedGrid.SortField == null || pagedGrid.SortField == "") ? "" : (" order by " + pagedGrid.SortField + " " + (pagedGrid.Desc ? "desc" : "asc"));
        }

        private void AddPageGrid()
        {
            pagedGrid.SetCanQuery();
            
            pagedGrid.Dock = DockStyle.Fill;
            this.tabControlPanel1.Controls.Add(pagedGrid);
        }

        private DataTable TurnPage(int from, int to)
        {
            DataTable pDataTable = GetDatum(from, to);
            if (pDataTable != null) return pDataTable;
            else
                return null;
        }

        private void chkUseCstExt_CheckedChanged(object sender, EventArgs e)
        {
            spgrdSheet.Enabled = chkUseCstExt.Checked;
            regionTree.Enabled = chkUseCstExt.Checked;
            btnDrawExtent.Enabled = chkUseCstExt.Checked;
        }

        private void btn_Del_Click(object sender, EventArgs e)
        {
            int index = dataGridViewX1.CurrentCell.RowIndex;
            if (index < 0)
            {
                MsgHelper.ShowInfomationMsgbox("未选中任何行");
                return;
            }
            else
            {
                dataGridViewX1.Rows.Remove(dataGridViewX1.CurrentRow);
            }
        }

        private void FrmCustomReport_FormClosed(object sender, FormClosedEventArgs e)
        {
            (m_Application as IFramework).Tool = null;
            if (_SheetCreator != null) _SheetCreator.ClearElement();
            if (_ToolCreator != null) _ToolCreator.Clear();
            regionTree.ClearNodeCheck(regionTree.Nodes);
            regionTree.Clear();

            IActiveView pAV = (m_Application.Document as IMxDocument).ActiveView;

            IGraphicsContainer pGeoContainer = pAV as IGraphicsContainer;

            if (m_pElementUserDraw != null)
            {
                try
                {
                    pGeoContainer.DeleteElement(m_pElementUserDraw);
                    //IActiveView pAV = ((AxMapControl)statusController.Host).ActiveView;
                    pAV.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, pAV.Extent);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
        }

        private void sptbctlGeo_SelectedTabChanged(object sender, SuperTabStripSelectedTabChangedEventArgs e)
        {
            cmbScale.Visible = this.sptbctlGeo.SelectedTab == sptbitmSheet;
            if (chkUseCstExt.Checked == false) return;
            IGraphicsContainer pGraphicsContainer = (IGraphicsContainer)(m_Application.Document as IMxDocument).ActiveView;
            pGraphicsContainer.DeleteAllElements();
            if (this.sptbctlGeo.SelectedTab == sptbitmSheet && _SheetCreator.CheckedSheets != null)
            {
                _SheetCreator.ClearElement();
                _SheetCreator.DrawElements(_SheetCreator.CheckedSheets);
            }
            if (this.sptbctlGeo.SelectedTab == sptbitmRegion && regionTree.DrawElements != null)
            {
                foreach (IElement ele in regionTree.DrawElements)
                {
                    ElementHelper.AddElement(ele, (m_Application.Document as IMxDocument).ActiveView.FocusMap);
                }
            }
            (m_Application.Document as IMxDocument).ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics | esriViewDrawPhase.esriViewGeography, null, (m_Application.Document as IMxDocument).ActiveView.Extent);
            if (chkUseCstExt.Checked == true)
            {
                _ToolCreator.SetToolEnable("ToolDrawLine", (this.sptbctlGeo.SelectedTab == sptbitmSheet
                    || this.sptbctlGeo.SelectedTab == sptbitmRegion));
            }
        }

        private void btnSelAllSheet_Click(object sender, EventArgs e)
        {
            foreach (GridRow r in spgrdSheet.PrimaryGrid.Rows)
            {
                if ((bool)r.Cells["colCheck"].Value == false)
                {
                    r.Cells["colCheck"].Value = true;
                    Mapsheet sheet = r.Tag as Mapsheet;
                    int idx = _SheetCreator.AllSheets.FindIndex(t => t.Code == sheet.Code);
                    if (idx > -1)
                    {
                        if (_SheetCreator.AllSheets[idx].Checked == false)
                            _SheetCreator.AllSheets[idx].Checked = true;
                    }
                }
            }
            _SheetCreator.ClearElement();
            _SheetCreator.DrawElements(_SheetCreator.CheckedSheets);
        }

        private void btnNoSelSheet_Click(object sender, EventArgs e)
        {
            foreach (GridRow r in spgrdSheet.PrimaryGrid.Rows)
            {
                if ((bool)r.Cells["colCheck"].Value == true)
                {
                    r.Cells["colCheck"].Value = false;
                    Mapsheet sheet = r.Tag as Mapsheet;
                    int idx = _SheetCreator.AllSheets.FindIndex(t => t.Code == sheet.Code);
                    if (idx > -1)
                    {
                        if (_SheetCreator.AllSheets[idx].Checked == true)
                            _SheetCreator.AllSheets[idx].Checked = false;
                    }
                }
            }
            _SheetCreator.ClearElement();
            _SheetCreator.DrawElements(_SheetCreator.CheckedSheets);
        }

        private void btnReverSelSheet_Click(object sender, EventArgs e)
        {
            foreach (GridRow r in spgrdSheet.PrimaryGrid.Rows)
            {
                if ((bool)r.Cells["colCheck"].Value == true)
                {
                    r.Cells["colCheck"].Value = false;
                    Mapsheet sheet = r.Tag as Mapsheet;
                    int idx = _SheetCreator.AllSheets.FindIndex(t => t.Code == sheet.Code);
                    if (idx > -1)
                    {
                        if (_SheetCreator.AllSheets[idx].Checked == true)
                            _SheetCreator.AllSheets[idx].Checked = false;
                    }
                }
                else if ((bool)r.Cells["colCheck"].Value == false)
                {
                    r.Cells["colCheck"].Value = true;
                    Mapsheet sheet = r.Tag as Mapsheet;
                    int idx = _SheetCreator.AllSheets.FindIndex(t => t.Code == sheet.Code);
                    if (idx > -1)
                    {
                        if (_SheetCreator.AllSheets[idx].Checked == false)
                            _SheetCreator.AllSheets[idx].Checked = true;
                    }
                }
            }
            _SheetCreator.ClearElement();
            _SheetCreator.DrawElements(_SheetCreator.CheckedSheets);
        }

        private void cmbScale_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(cmbScale.Text)) return;
            if (_SheetCreator == null) return;
            _SheetCreator.ScaleValue = int.Parse(cmbScale.Text);
        }
    }
}
